View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.jms;
8   
9   import org.mule.api.construct.FlowConstruct;
10  import org.mule.api.endpoint.InboundEndpoint;
11  import org.mule.api.lifecycle.CreateException;
12  import org.mule.api.transport.Connector;
13  
14  import javax.jms.Message;
15  import javax.jms.MessageListener;
16  
17  /**
18   * Registers a single Jms MessageListener for an endpoint
19   */
20  public class SingleJmsMessageReceiver extends JmsMessageReceiver implements MessageListener
21  {
22  
23      public SingleJmsMessageReceiver(Connector connector, FlowConstruct flowConstruct, InboundEndpoint endpoint)
24              throws CreateException
25      {
26          super(connector, flowConstruct, endpoint);
27      }
28  
29  
30      public void onMessage(Message message)
31      {
32          try
33          {
34              JmsWorker worker = new JmsWorker(message, this);
35              worker.run();
36          }
37          catch (Exception e)
38          {
39              getConnector().getMuleContext().getExceptionListener().handleException(e);
40          }
41      }
42  }