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 IndexIBM MQ Installation/Configuration SupportFailed to send a message to destination

Post new topicReply to topic Goto page 1, 2, 3  Next
Failed to send a message to destination View previous topic :: View next topic
Author Message
kalam475
PostPosted: Wed Feb 01, 2017 3:24 am Post subject: Failed to send a message to destination Reply with quote

Acolyte

Joined: 16 Jan 2015
Posts: 56

Hi,

I have written a webservice which accepts the json messages and put the messages in queue. Below is the code snippet

Code:

try {
         context = new InitialContext();
         String connectionFactoryString = System.getProperty("connection.factory", MQProperties.mqJNDI);
         connectionFactory = (ConnectionFactory) context.lookup(connectionFactoryString);
         String destinationString = System.getProperty("destination", MQProperties.mqDest);
         destination = (Destination) context.lookup(destinationString);
         connection = connectionFactory.createConnection();
         session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
         producer = session.createProducer(destination);
         connection.start();
         message = session.createTextMessage(input);
         producer.send(message);
         response="Sucess";
      } catch (Exception e) {
      response="Failed";
         System.out.println("Error while connecting to JNDI   "+e.getMessage());
      }
        finally {
         try {
            if (producer != null)
               producer.close();
            if (connection != null)
               connection.close();
            if (session != null)
               session.close();
         } catch (JMSException e) {
            // TODO Auto-generated catch block
            System.out.println("Unable to close the connection   " + e.getMessage());
         }
      }
         System.out.println("Result   "+response);





When my webservice is hit continiously and my queue manager stops abruptly ideally i should get a status of failed message.


this Webservice is hosted on a WebSphere Application server and connected to a queue manager through connection factory connecting to Multi Instance queue manager.

The problem here is when my queue manager is stoped abruptly or switched to standby queue manager I am getting error in system.out logs of WAS as "JMSWMQ2007: Failed to send a message to destination" and failed status message which is fine. But when I see the queue the message is available in queue.

I think i had to handle this problem don't know how please help

Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed Feb 01, 2017 4:29 am Post subject: Reply with quote

Jedi Council

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

If I may summarise

Everything is working fine but when you basically pull the rug from under the application you get an error.

On the surface this is working as designed.

However, the Queue Manager will emit a number of messages when it is shutting down.
How JMS communicates this to the caller I will have to leave to a JMS expert but there should be one way of detecting at least one of the change of states of the QMGR when it fails over.

Also, perhaps you might like to make the application terminate when the QMGR goes down. If you are using Windows MSCS then you can make the application a service thar has a dependency on MQ. That way it will be started and stopped on the correct server along with the Queue Manager.
I am sure that other clustering techniques can do the same.
_________________
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: Wed Feb 01, 2017 5:29 am Post subject: Re: Failed to send a message to destination Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 24614
Location: Ohio, USA

kalam475 wrote:
But when I see the queue the message is available in queue.


So how do you know the message was not successfully put before the queue manager went down? Do you still see a message and/or a lack of application errors if you run your application with the queue manager stopped?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kalam475
PostPosted: Wed Feb 01, 2017 5:41 am Post subject: Reply with quote

Acolyte

Joined: 16 Jan 2015
Posts: 56

When "producer.send()" is executed the messages is sent into the queue, but sometimes after sending the message to queue I'm receiving Exception: JMSWMQ2007 . Normally this exception occurs when the application is unable to put the message into queue. But in my case the message went to queue and returning exception. Due to this exception it is catch block and printing the final response as "Failed".
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Feb 01, 2017 5:46 am Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 24614
Location: Ohio, USA

kalam475 wrote:
Normally this exception occurs when the application is unable to put the message into queue.


That exception is a generic JMS exception that you get under 80% of circumstances. Look in the linked exception for the actual MQ reason code - it's highly plausible that the JMS exception is MQ reporting that the connection has failed rather than that the put operation has failed.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kalam475
PostPosted: Wed Feb 01, 2017 6:02 am Post subject: Reply with quote

Acolyte

Joined: 16 Jan 2015
Posts: 56

Below is the complete Exception:

com.ibm.msg.client.jms.DetailedJMSException: JMSWMQ2007: Failed to send a message to destination 'PaymentRequest'.
JMS attempted to perform an MQPUT or MQPUT1; however WebSphere MQ reported an error.
Use the linked exception to determine the cause of this error.:com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2009' ('MQRC_CONNECTION_BROKEN').:com.ibm.mq.jmqi.JmqiException: CC=2;RC=2009:com.ibm.mq.jmqi.JmqiException: CC=2;RC=2009
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Feb 01, 2017 6:16 am Post subject: Reply with quote

Grand Poobah

Joined: 18 Nov 2003
Posts: 19382
Location: LI,NY

A lot of this depends on how you set up your connection / connection factory in WAS. Did you use the connection Name List? (in my opinion mandatory with MI)
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
smdavies99
PostPosted: Wed Feb 01, 2017 7:08 am Post subject: Reply with quote

Jedi Council

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

the MQRC=2009 tells you everything you need to know. your client connection to the QMGR has been broken.

When you get this, you could always try reconnecting. Just a suggestion.

Welcome to the world of desiging and implementing a resilient client application
_________________
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
zpat
PostPosted: Wed Feb 01, 2017 7:52 am Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5559
Location: UK

Or use the MQ client auto-reconnect feature which should hide the MQRC 2009 from the application.
_________________
Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Wed Feb 01, 2017 8:09 am Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 7845
Location: US: west coast, almost. Otherwise, enroute.

smdavies99 wrote:
the MQRC=2009 tells you everything you need to know. your client connection to the QMGR has been broken.

Mmmmm, perhaps not everything.

You should look in the error logs on BOTH client platform and server platform.
_________________
I didn't know that Schrdinger had a cat.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed Feb 01, 2017 9:51 am Post subject: Reply with quote

Jedi Council

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

bruce2359 wrote:
smdavies99 wrote:
the MQRC=2009 tells you everything you need to know. your client connection to the QMGR has been broken.

Mmmmm, perhaps not everything.

You should look in the error logs on BOTH client platform and server platform.


True but the OP did mention failover a Queue Manager. IMHO, a 2009 is sort of par for the course when the app uses a client connection. OTher error codes are possible though.
But look at the logs compare the events + timestamps.
_________________
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
kalam475
PostPosted: Wed Feb 01, 2017 10:10 am Post subject: Reply with quote

Acolyte

Joined: 16 Jan 2015
Posts: 56

Quote:
A lot of this depends on how you set up your connection / connection factory in WAS. Did you use the connection Name List?


yes i have tried with both connection namelist and CCDT file to connect to queue manager through connection factory.but same issue.


If I'm not wrong when we use re-connection logic in code it will create a new session. If that is the case i can't commit or rollback the transaction since sometimes i'm getting this exception before sending message and some times after sending message.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Feb 01, 2017 10:39 am Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 24614
Location: Ohio, USA

So what you're saying is that if you abruptly terminate the queue manager while your application is running, a message is put to the queue and you receive a 2009 error for the same put operation.

You're saying that the message is put to the queue and you get an error message saying it wasn't.

Not that one message makes it to the queue and another message put at or about the same time gets the error. That the message visible on the queue was placed there by an operation to which MQ responded with a 2009.

Time for a PMR.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Feb 01, 2017 12:10 pm Post subject: Reply with quote

Grand Poobah

Joined: 18 Nov 2003
Posts: 19382
Location: LI,NY

Vitor wrote:
So what you're saying is that if you abruptly terminate the queue manager while your application is running, a message is put to the queue and you receive a 2009 error for the same put operation.

You're saying that the message is put to the queue and you get an error message saying it wasn't.

Not that one message makes it to the queue and another message put at or about the same time gets the error. That the message visible on the queue was placed there by an operation to which MQ responded with a 2009.

Time for a PMR.

Can totally happen on a client connection. The put did not happen and you get a 2009, or the put did happen and before the qmgr could respond positively the connection got broken and you still get a 2009... (client side).
Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Wed Feb 01, 2017 12:25 pm Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 24614
Location: Ohio, USA

fjb_saper wrote:
the put did happen and before the qmgr could respond positively the connection got broken and you still get a 2009... (client side).


Really? If the queue manager has failed to handshake with the client, wouldn't it roll back the message? Or at least leave it uncommitted?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Goto page 1, 2, 3  Next Page 1 of 3

MQSeries.net Forum IndexIBM MQ Installation/Configuration SupportFailed to send a message to destination
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.