View Javadoc

1   /*
2    * $Id: MessageReceiver.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.api.transport;
12  
13  import org.mule.api.MuleEvent;
14  import org.mule.api.MuleException;
15  import org.mule.api.MuleMessage;
16  import org.mule.api.construct.FlowConstruct;
17  import org.mule.api.endpoint.EndpointURI;
18  import org.mule.api.endpoint.ImmutableEndpoint;
19  import org.mule.api.endpoint.InboundEndpoint;
20  import org.mule.api.source.MessageSource;
21  import org.mule.api.transaction.Transaction;
22  
23  import java.io.OutputStream;
24  
25  /**
26   * <code>MessageReceiver</code> is used to receive data from an external system.
27   * Typically an implementation of this interface will also implement the listener
28   * interface for the external system. For example to listen to a JMS destination the
29   * developer would also implement javax.jms.MessageListener. The endpoint (which
30   * creates the MessageReceiver) will then register the receiver with the JMS
31   * server. Where a listener interface is not availiable the derived
32   * <code>MessageReceiver</code> will implement the code necessary to receive
33   * data from the external system. For example, the file endpoint will poll a
34   * specified directory for its data.
35   */
36  public interface MessageReceiver extends Connectable, MessageSource
37  {
38      /**
39       * @return the endpoint from which we are receiving events 
40       */
41      InboundEndpoint getEndpoint();
42  
43      /**
44       * @return the service associated with the receiver
45       */
46      FlowConstruct getFlowConstruct();
47  
48      /**
49       * @param endpoint the endpoint to listen on
50       * @see ImmutableEndpoint
51       */
52      void setEndpoint(InboundEndpoint endpoint);
53  
54      /**
55       * The endpointUri that this receiver listens on
56       */
57      EndpointURI getEndpointURI();
58  
59      String getReceiverKey();
60  
61      void setReceiverKey(String key);
62  
63      MuleEvent routeMessage(MuleMessage message) throws MuleException;
64  
65      MuleEvent routeMessage(MuleMessage message, Transaction trans) throws MuleException;
66  
67      MuleEvent routeMessage(MuleMessage message, Transaction trans, OutputStream outputStream)
68          throws MuleException;
69      
70      MuleMessage createMuleMessage(Object transportMessage, String encoding) throws MuleException;
71  
72      MuleMessage createMuleMessage(Object transportMessage) throws MuleException;
73  }