1 /* 2 * $Id: UMOMessageDispatching.java 7963 2007-08-21 08:53:15Z dirk.olmes $ 3 * -------------------------------------------------------------------------------------- 4 * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.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.umo.provider; 12 13 import org.mule.umo.UMOEvent; 14 import org.mule.umo.UMOMessage; 15 16 /** 17 * <code>UMOMessageDispatching</code> defines generic methods for dispatching and 18 * receiving events. The exact behaviour of the action is defined by the implementing 19 * class. 20 * 21 * @see org.mule.umo.endpoint.UMOImmutableEndpoint 22 * @see org.mule.umo.provider.UMOMessageDispatcher 23 */ 24 public interface UMOMessageDispatching 25 { 26 long RECEIVE_WAIT_INDEFINITELY = 0; 27 long RECEIVE_NO_WAIT = -1; 28 29 /** 30 * Dispatches an event from the endpoint to the external system 31 * 32 * @param event The event to dispatch 33 * @throws DispatchException if the event fails to be dispatched 34 */ 35 void dispatch(UMOEvent event) throws DispatchException; 36 37 /** 38 * Sends an event from the endpoint to the external system 39 * 40 * @param event The event to send 41 * @return event the response form the external system wrapped in a UMOEvent 42 * @throws DispatchException if the event fails to be dispatched 43 */ 44 UMOMessage send(UMOEvent event) throws DispatchException; 45 46 /** 47 * Make a specific request to the underlying transport 48 * 49 * @param timeout the maximum time the operation should block before returning. 50 * The call should return immediately if there is data available. If 51 * no data becomes available before the timeout elapses, null will be 52 * returned 53 * @return the result of the request wrapped in a UMOMessage object. Null will be 54 * returned if no data was avaialable 55 * @throws Exception if the call to the underlying protocal cuases an exception 56 */ 57 UMOMessage receive(long timeout) throws Exception; 58 59 }