ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Read all messages from Queue and send email

Post new topic  Reply to topic Goto page 1, 2  Next
 Read all messages from Queue and send email « View previous topic :: View next topic » 
Author Message
Sai K
PostPosted: Wed Jul 13, 2011 5:10 pm    Post subject: Read all messages from Queue and send email Reply with quote

Novice

Joined: 23 Jun 2011
Posts: 22

Hi All,

I have a requirement to read all the messages from queue(each message has different account number) and construct the email body that has all the account numbers and generate one email.
Please suggest me the solution for this !!
Back to top
View user's profile Send private message
mqsiuser
PostPosted: Wed Jul 13, 2011 11:29 pm    Post subject: Re: Read all messages from Queue and send email Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

I think you can use a MQGet-Node and wire it so that you create a loop to get several messages into your (single) flow (instance).

You need to trigger the flow with a MQInput-Node and a message before starting to loop and using MQGet.

While you are looping you need to put the data (that you want to emit at the end) into the Envrionment.

At the end you put the data from the environment into the output message.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Thu Jul 14, 2011 1:51 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

You can use the last suggestion but you might very well endup blowing up (aka causung an abend) your Execution Group.

You gave us no details of the frequency of the consolidation emails
You gave us no details of the volumes of messages.

Without that we can't really help you out except to point out possible bad design choices.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
mqsiuser
PostPosted: Thu Jul 14, 2011 2:15 am    Post subject: Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

yes, think about resource-limitations !

For regularly getting all messages off the queue you might use a TimeoutNotification-Node. You can configure it to e.g. 5 minutes intervall, so all 5 minutes the flow is triggered.

So instead of a MQInput-Node (and an input queue) put in the TimeoutNotification-Node and let it trigger the MQGet-Node.

If no messages are on the (Get-)queue you can discard to send the eMail (within your flow).
Back to top
View user's profile Send private message
zpat
PostPosted: Thu Jul 14, 2011 3:58 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

If you use repeated propagates to a MQGET node then you won't blow the execution stack.
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Jul 14, 2011 4:56 am    Post subject: Re: Read all messages from Queue and send email Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Sai K wrote:
I have a requirement to read all the messages from queue(each message has different account number) and construct the email body that has all the account numbers and generate one email.


How do you know that you have to generate the email? Is it based on time of day or is there some flag?

How do you know that all the messages go on a single email? Do the messages (with different account numbers) have something in common to group them? Would there ever be an instance where you'd want them on 2 emails?

How do you know that there won't be so many messages in the queue that the email system will reject the email as being too large?

If the messages have something in common I'd use an MQInput node and a Collector node to assemble them. Once you have them as a single message tree, itterating round it to produce a single email body is simple.

If the messages have nothing in common I'd use an MQInput node and a Collector node to assemble them. Once you have them as a single message tree, itterating round it to produce a single email body is simple.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
zpat
PostPosted: Thu Jul 14, 2011 5:59 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

You may want to use the "groupid" feature of MQ, so that the message flow does not start until the entire group of MQ messages has arrived on the queue.

Otherwise it will process those on the queue when the flow starts - I have done something very similar (except to a file) and chose to repeatedly propagate control from a compute node to a MQGET node setting a MQGMO_WAIT value of 120 seconds. That way I allowed some time for a batch of messages to arrive. Grouping is a better way though.
Back to top
View user's profile Send private message
Sai K
PostPosted: Thu Jul 14, 2011 7:09 am    Post subject: Reply with quote

Novice

Joined: 23 Jun 2011
Posts: 22

I need to generate the email for every one hour, approximately there will be 40 to 50 messages in the queue.

All the messages has the common group id.
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Jul 14, 2011 7:26 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Sai K wrote:
I need to generate the email for every one hour, approximately there will be 40 to 50 messages in the queue.

All the messages has the common group id.


Then you need a combination of the suggestions from here. Read the messages with an MQInput node configured to only read complete groups, pass all those messages through a Collector node then itterate through the collection to produce the email.

Simples (I'm in touch with my inner meercat)
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
zpat
PostPosted: Thu Jul 14, 2011 8:11 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

Don't forget that the sending application has to set the groupid and mark the last one as "end of group".

Then the MQinput node has to have "all messages available" selected (and I would also select "logical order").

This will cause the flow to start processing, on the first message, when the group is ready on the queue.

But you still need to handle the repeated MQGET loop for each subsequent message (making sure you only get the ones you want from the same group) until you reach the end of the group.

It's a little complicated to handle this with propagate logic - you have to pass data back in the environment variables to the main compute loop (and tell it when the last message has been received so it can end the loop).

A node wired loop is more obvious - but it will get a stack overflow if you have more than about 100-200 messages.
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Jul 14, 2011 8:24 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

zpat wrote:
But you still need to handle the repeated MQGET loop for each subsequent message (making sure you only get the ones you want from the same group) until you reach the end of the group.


No, just use an MQInput node to get them all.

zpat wrote:
It's a little complicated to handle this with propagate logic - you have to pass data back in the environment variables to the main compute loop (and tell it when the last message has been received so it can end the loop).


That's why you use a Collector node not a loop & propagate. It's a lot easier and you get WMB to do the work for you.

zpat wrote:
A node wired loop is more obvious - but it will get a stack overflow if you have more than about 100-200 messages.


Again, an MQinput node and a Collector avoids this problem.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Thu Jul 14, 2011 8:49 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Look at the Input Terminals of the CollectorNode.

There is one that is ideally suited to being triggered by a timer node.

Simples....

Actually your biggest problem is going to be navigating to the correct element in the collection. To see what I mean put a trace node set to ${Root} on the output of the collector node. Then put a few 2-3 message into the collection and trigger it. A few careful ESQL references and you are all set to loop (in ESQL) through the collection and gather all the data you are going to need for the email.

There are a number of posts in this forum about sending emails. Use these PLUS the email sample flow modified to include a trace of the Root & LocalEnvironment before the emailoutput node will tell you everything you need to know.

Enjoy.

Simples my meerkat friend.
{They are an awful lot better than that Go-C??????? lot. IMHO}
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Jul 14, 2011 8:58 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

smdavies99 wrote:
Look at the Input Terminals of the CollectorNode.

There is one that is ideally suited to being triggered by a timer node.


If you know that everything for a given email is in the same group & the MQInput node only reads complete groups, you don't even need that.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Thu Jul 14, 2011 9:14 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Vitor wrote:
smdavies99 wrote:
Look at the Input Terminals of the CollectorNode.

There is one that is ideally suited to being triggered by a timer node.


If you know that everything for a given email is in the same group & the MQInput node only reads complete groups, you don't even need that.


Agreed but that relied on being able to set up the sending application/applications correctly. I'm sure you will agree that this is often not the case. My method requires no modification of the sender(s).

Both are equally valid.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
Sai K
PostPosted: Thu Jul 14, 2011 10:10 am    Post subject: Reply with quote

Novice

Joined: 23 Jun 2011
Posts: 22

I designed the message flow like this ..
MQinput --> compute --> collector-- >compute -- >emailoutput
MQinput node properties: Commit by message group(Checked)
All messages available(checked)
When I put 5 messages in mqinput node, all those messages are available after the collector node. But message body is not showing in that structure.
If I got that xml structure, I will loop all the account numbers and generate email.

I can not able to attach the image.. this is structure from the debugger..
Message has properties and MQMd, but it does not has XMLNSC.
CollectionName:CHARACTER:Control
Message
Properties
MessageSet:CHARACTER:
MessageType:CHARACTER:
MessageFormat:CHARACTER:
Encoding:INTEGER:546
CodedCharSetId:INTEGER:437
Transactional:BOOLEAN:true
Persistence:BOOLEAN:false
CreationTime:TIMESTAMP:java.util.GregorianCalendar[time=1310682980950,areFieldsSet=true,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Chicago",offset=-21600000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/Chicago,offset=-21600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=?,YEAR=2011,MONTH=6,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=14,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=1,HOUR=5,HOUR_OF_DAY=17,MINUTE=36,SECOND=20,MILLISECOND=950,ZONE_OFFSET=?,DST_OFFSET=?]
ExpirationTime:INTEGER:-1
Priority:INTEGER:0
ReplyIdentifier:BLOB:[B@2d722d72
ReplyProtocol:CHARACTER:UNKNOWN
Topic:CHARACTER:
ContentType:UNKNOWN:null
IdentitySourceType:UNKNOWN:null
IdentitySourceToken:UNKNOWN:null
IdentitySourcePassword:UNKNOWN:null
IdentitySourceIssuedBy:UNKNOWN:null
IdentityMappedType:UNKNOWN:null
IdentityMappedToken:UNKNOWN:null
IdentityMappedPassword:UNKNOWN:null
IdentityMappedIssuedBy:UNKNOWN:null
MQMD
SourceQueue:CHARACTER:
Transactional:BOOLEAN:true
Encoding:INTEGER:546
CodedCharSetId:INTEGER:437
Format:CHARACTER:
Version:INTEGER:2
Report:INTEGER:0
MsgType:INTEGER:8
Expiry:INTEGER:-1
Feedback:INTEGER:0
Priority:INTEGER:0
Persistence:INTEGER:0
MsgId:BLOB:[B@451a451a
CorrelId:BLOB:[B@45c245c2
BackoutCount:INTEGER:0
ReplyToQ:CHARACTER:
ReplyToQMgr:CHARACTER:MB7QMGR
UserIdentifier:CHARACTER:Kothapalli
AccountingToken:BLOB:[B@499c499c
ApplIdentityData:CHARACTER:
PutApplType:INTEGER:11
PutApplName:CHARACTER:lli\Desktop\ih03\rfhutil.exe
PutDate:DATE:java.util.GregorianCalendar[time=1310619600000,areFieldsSet=true,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Chicago",offset=-21600000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/Chicago,offset=-21600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=?,YEAR=2011,MONTH=6,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=14,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=?,ZONE_OFFSET=?,DST_OFFSET=?]
PutTime:TIME:java.util.GregorianCalendar[time=-62167393419050,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Chicago",offset=-21600000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/Chicago,offset=-21600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=0,YEAR=2,MONTH=11,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=31,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=1,HOUR=5,HOUR_OF_DAY=17,MINUTE=36,SECOND=20,MILLISECOND=950,ZONE_OFFSET=?,DST_OFFSET=?]
ApplOriginData:CHARACTER:
GroupId:BLOB:[B@51885188
MsgSeqNumber:INTEGER:1
Offset:INTEGER:0
MsgFlags:INTEGER:0
OriginalLength:INTEGER:-1
Message
Properties
MessageSet:CHARACTER:
MessageType:CHARACTER:
MessageFormat:CHARACTER:
Encoding:INTEGER:546
CodedCharSetId:INTEGER:437
Transactional:BOOLEAN:true
Persistence:BOOLEAN:false
CreationTime:TIMESTAMP:java.util.GregorianCalendar[time=1310684509600,areFieldsSet=true,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Chicago",offset=-21600000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/Chicago,offset=-21600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=?,YEAR=2011,MONTH=6,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=14,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=1,HOUR=6,HOUR_OF_DAY=18,MINUTE=1,SECOND=49,MILLISECOND=600,ZONE_OFFSET=?,DST_OFFSET=?]
ExpirationTime:INTEGER:-1
Priority:INTEGER:0
ReplyIdentifier:BLOB:[B@5ecc5ecc
ReplyProtocol:CHARACTER:UNKNOWN
Topic:CHARACTER:
ContentType:UNKNOWN:null
IdentitySourceType:UNKNOWN:null
IdentitySourceToken:UNKNOWN:null
IdentitySourcePassword:UNKNOWN:null
IdentitySourceIssuedBy:UNKNOWN:null
IdentityMappedType:UNKNOWN:null
IdentityMappedToken:UNKNOWN:null
IdentityMappedPassword:UNKNOWN:null
IdentityMappedIssuedBy:UNKNOWN:null
MQMD
SourceQueue:CHARACTER:
Transactional:BOOLEAN:true
Encoding:INTEGER:546
CodedCharSetId:INTEGER:437
Format:CHARACTER:
Version:INTEGER:2
Report:INTEGER:0
MsgType:INTEGER:8
Expiry:INTEGER:-1
Feedback:INTEGER:0
Priority:INTEGER:0
Persistence:INTEGER:0
MsgId:BLOB:[B@70307030
CorrelId:BLOB:[B@70d870d8
BackoutCount:INTEGER:0
ReplyToQ:CHARACTER:
ReplyToQMgr:CHARACTER:MB7QMGR
UserIdentifier:CHARACTER:Kothapalli
AccountingToken:BLOB:[B@74f674f6
ApplIdentityData:CHARACTER:
PutApplType:INTEGER:11
PutApplName:CHARACTER:lli\Desktop\ih03\rfhutil.exe
PutDate:DATE:java.util.GregorianCalendar[time=1310619600000,areFieldsSet=true,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Chicago",offset=-21600000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/Chicago,offset=-21600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=?,YEAR=2011,MONTH=6,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=14,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=?,ZONE_OFFSET=?,DST_OFFSET=?]
PutTime:TIME:java.util.GregorianCalendar[time=-62167391890400,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Chicago",offset=-21600000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/Chicago,offset=-21600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=0,YEAR=2,MONTH=11,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=31,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=1,HOUR=6,HOUR_OF_DAY=18,MINUTE=1,SECOND=49,MILLISECOND=600,ZONE_OFFSET=?,DST_OFFSET=?]
ApplOriginData:CHARACTER:
GroupId:BLOB:[B@92a092a
MsgSeqNumber:INTEGER:1
Offset:INTEGER:0
MsgFlags:INTEGER:0
OriginalLength:INTEGER:-1

I appreciate for all your responses. Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Read all messages from Queue and send email
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.