01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.servicemix.jbi.nmr.flow.st;
18:
19: import javax.jbi.messaging.MessageExchange;
20: import javax.jbi.messaging.MessagingException;
21:
22: import org.apache.servicemix.jbi.messaging.MessageExchangeImpl;
23: import org.apache.servicemix.jbi.nmr.flow.AbstractFlow;
24: import org.apache.servicemix.jbi.servicedesc.AbstractServiceEndpoint;
25:
26: /**
27: * A simple Straight through flow.
28: *
29: * A MessageExchange is routed straight to it's destination with
30: * no staging or buffering. A straight through flow is best suited
31: * for the cases where the ServiceMix JBIContainer is deployed with simple
32: * flows (no state) or embedding, or where latency needs to be as low as possible.
33: *
34: * @version $Revision: 564607 $
35: * @org.apache.xbean.XBean element="stFlow"
36: */
37: public class STFlow extends AbstractFlow {
38:
39: /**
40: * Distribute an ExchangePacket
41: *
42: * @param packet
43: * @throws MessagingException
44: */
45: protected void doSend(MessageExchangeImpl me)
46: throws MessagingException {
47: if (me.getDestinationId() == null) {
48: me.setDestinationId(((AbstractServiceEndpoint) me
49: .getEndpoint()).getComponentNameSpace());
50: }
51: doRouting(me);
52: }
53:
54: /**
55: * The type of Flow
56: * @return the type
57: */
58: public String getDescription() {
59: return "st";
60: }
61:
62: /**
63: * Check if the flow can support the requested QoS for this exchange
64: * @param me the exchange to check
65: * @return true if this flow can handle the given exchange
66: */
67: public boolean canHandle(MessageExchange me) {
68: if (isPersistent(me)) {
69: return false;
70: }
71: if (isClustered(me)) {
72: return false;
73: }
74: // We can not handle transactional exchanges:
75: // * asynchronous is a bit weird when the transaction is conveyed
76: // * synchronous could lead to deadlock if the provider uses Push delivery
77: if (isTransacted(me)) {
78: return false;
79: }
80: return true;
81: }
82:
83: }
|