If I am reading your mail correctly, this sounds like its working as it should.

Either the async send method returns normally because it sent the
message, and you are then notified of the result asynchronously via
the CompletionListener (which may be success or failure depending on
if the message was successfully accepted by the server), or the async
send call fails and throws immediately because it didnt get as far as
actually sending the message (e.g because the producer was closed
before it was able to). If the producer was closed before you try to
send, which is what you are most likely to see in this scenario where
its closed because you didnt use it, the send call itself will throw.

Robbie

On 31 May 2018 at 17:06, akabhishek1 <[email protected]> wrote:
> Hi Robbie And Team,
>
> After your suggetion for handling exception for Producer in Catch Block and
> create again once Producer closed. I implemented this scenario. I can get
> exception with the use of CompletionListener only. So everytime i need to
> supply CompletionHandler for handling exception.
>
> For successful scenario - I am getting callback in
> SendCompletionHandler-->onCompletion method which is perfect.
> For Failed Scenario -- I am getting exception on catch block() of dispatch
> operation. But i am not getting callback on
> SendCompletionHandler-->onException ? Please find below code snippet.
>
> I have doubt on this, Why i am not getting callback on
> "SendCompletionHandler-->onException" ?
> Could you please suggest, why i am not getting callback on "onException"
> operation or implementation is working perfectly.
>
>
> //////// Code
>
>         //Global var
>         SendCompletionHandler sendCompletionHandler = new 
> SendCompletionHandler();
>
>         public void dispatch(){
>                 try {
>                         producer.send(message, sendCompletionHandler);
>                 } catch (IllegalStateException illegalStateException) { // 
> *** Getting
> Exception Callback here ***
>                         System.err.println("*** 
> illegalStateException.getMessage() ***" +
> illegalStateException.getMessage());
>
>                         if (illegalStateException.getMessage().contains("The 
> MessageProducer is
> closed")) {
>                                 // Reset Producer due to Idle TimeOut after 
> 10m
>                                 producer = createProducer(session, endpoint);
>                                 producer.send(message, 
> sendCompletionHandler));
>                         }else{
>                                 throw illegalStateException;
>                         }
>                 }
>         }
>
>         class SendCompletionHandler implements CompletionListener {
>
>                 @Override
>                 public void onCompletion(Message message) {
>                         logger.info("Completed JMSMessageID :: " + 
> message.getJMSMessageID());
>                 }
>
>                 @Override
>                 public void onException(Message message, Exception exception) 
> {
>                         try {
>                                 logger.error("Failed message JMSMessageID :: 
> " +
> message.getJMSMessageID());
>                         } catch (JMSException e) {
>                                 e.printStackTrace();
>                         }
>
>                 }
>
>         }
>
>         Regards,
>         Abhishek Kumar
>
>
>
> --
> Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to