01: /*
02: * $Id: MessageReceiver.java 10961 2008-02-22 19:01:02Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10:
11: package org.mule.api.transport;
12:
13: import org.mule.api.MuleException;
14: import org.mule.api.MuleMessage;
15: import org.mule.api.endpoint.EndpointURI;
16: import org.mule.api.endpoint.ImmutableEndpoint;
17: import org.mule.api.endpoint.InboundEndpoint;
18: import org.mule.api.lifecycle.Lifecycle;
19: import org.mule.api.service.Service;
20: import org.mule.api.transaction.Transaction;
21:
22: import java.io.OutputStream;
23:
24: /**
25: * <code>MessageReceiver</code> is used to receive data from an external system.
26: * Typically an implementation of this interface will also implement the listener
27: * interface for the external system. For example to listen to a JMS destination the
28: * developer would also implement javax.jms.MessageListener. The endpoint (which
29: * creates the MessageReceiver) will then register the receiver with the JMS
30: * server. Where a listener interface is not availiable the derived
31: * <code>MessageReceiver</code> will implement the code necessary to receive
32: * data from the external system. For example, the file endpoint will poll a
33: * specified directory for its data.
34: */
35: public interface MessageReceiver extends Lifecycle, Connectable {
36: /**
37: * @return the receivers endpoint
38: */
39: InboundEndpoint getEndpoint();
40:
41: /**
42: * @param message
43: * @param exception
44: */
45: // void handleException(Object message, Throwable exception);
46: /**
47: * @return the service associated with the receiver
48: */
49: Service getService();
50:
51: /**
52: * @param endpoint the endpoint to listen on
53: * @see ImmutableEndpoint
54: */
55: void setEndpoint(InboundEndpoint endpoint);
56:
57: /**
58: * @param service the service to associate with the receiver. When data is
59: * received the service <code>dispatchEvent</code> or
60: * <code>sendEvent</code> is used to dispatch the data to the
61: * relivant UMO.
62: */
63: void setService(Service service);
64:
65: void setConnector(Connector connector);
66:
67: Connector getConnector();
68:
69: /**
70: * The endpointUri that this receiver listens on
71: *
72: * @return
73: */
74: EndpointURI getEndpointURI();
75:
76: String getReceiverKey();
77:
78: void setReceiverKey(String key);
79:
80: MuleMessage routeMessage(MuleMessage message) throws MuleException;
81:
82: MuleMessage routeMessage(MuleMessage message, boolean synchronous)
83: throws MuleException;
84:
85: MuleMessage routeMessage(MuleMessage message, Transaction trans,
86: boolean synchronous) throws MuleException;
87:
88: MuleMessage routeMessage(MuleMessage message,
89: OutputStream outputStream) throws MuleException;
90:
91: MuleMessage routeMessage(MuleMessage message, boolean synchronous,
92: OutputStream outputStream) throws MuleException;
93:
94: MuleMessage routeMessage(MuleMessage message, Transaction trans,
95: boolean synchronous, OutputStream outputStream)
96: throws MuleException;
97:
98: }
|