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 » IBM MQ Java / JMS » Is there a way to know if the message has received to a MQ?

Post new topic  Reply to topic
 Is there a way to know if the message has received to a MQ? « View previous topic :: View next topic » 
Author Message
fredand44
PostPosted: Wed Apr 02, 2008 6:26 am    Post subject: Is there a way to know if the message has received to a MQ? Reply with quote

Acolyte

Joined: 14 Feb 2006
Posts: 63

Hello!

I 'm running in a bean-managed-transacted environment in WebLogic.

I got a MDB consuming messages from a queue inside WebLogic.
The MDB should forward this message to a MQ queue.

In the MDB I'm doing like this:

onMessage(Message m)
{
sendMessageForwardToMq(m)
}

sendMessageForwardToMq(Message m)
{
Properties properties = new Properties();
properties.setProperty("java.naming.factory.initial", "com.sun.jndi.fscontext.RefFSContextFactory");
properties.setProperty("java.naming.provider.url", "file:C://folder");
Context ctxNaming = new InitialContext(properties);
QueueConnectionFactory factory = (QueueConnectionFactory) ctxNaming.lookup("MY_QUEUE_CON_FACT");
QueueConnection connection = factory.createQueueConnection();
connection.start();
QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = (Queue) ctxNaming.lookup("MY_QUEUE");
QueueSender sender = session.createSender(queue);
BytesMessage responseMessage = session.createBytesMessage();
responseMessage.writeBytes("a message".getBytes());
sender.send(responseMessage);
session.close();
connection.close();
}

Now I wonder if I could find out if the message successfully has arrived to MQ, before the method "sendMessageForwardToMq" returns?

Most thankfull for any comments.

Best regards
Fredrik
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Apr 02, 2008 6:40 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

If sender.send doesn't thrown an exception, then the message is sent.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fredand44
PostPosted: Wed Apr 02, 2008 10:40 am    Post subject: But can I be sure... Reply with quote

Acolyte

Joined: 14 Feb 2006
Posts: 63

Hello!

That came to me as well on the bus home!

No exception = No problems
Exception = Problems.

As you said ... message sent.
But can I be sure it arrived?

Best regards
Fredrik
Back to top
View user's profile Send private message
bower5932
PostPosted: Wed Apr 02, 2008 11:29 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

If you need to check arrival, you could look into using COA/COD (confirmation of arrival/delivery).
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
fredand44
PostPosted: Wed Apr 02, 2008 12:22 pm    Post subject: Hmm!! Reply with quote

Acolyte

Joined: 14 Feb 2006
Posts: 63

Hello!

Very interesting (COA)

I found this:
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/rmj_reports.html
But no examples.

Do you have any examples by any chance?

Best regards
Fredrik
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Apr 02, 2008 12:46 pm    Post subject: Re: Hmm!! Reply with quote

Grand High Poobah

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

fredand44 wrote:
Very interesting (COA)


Beware this slippery slope.

If you rely on COA messages to prove arrival, rather than relying on the years of patient research IBM have put into the product, then you need to code a mechanism for deailing with the situation where the message arrives ok, but the COA is delayed or lost.

This has been discussed before on the forum.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Apr 02, 2008 12:52 pm    Post subject: Re: Hmm!! Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Vitor wrote:
fredand44 wrote:
Very interesting (COA)


Beware this slippery slope.



_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Is there a way to know if the message has received to a MQ?
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.