⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transactedmessagereceiver.vm

📁 提供ESB 应用mule源代码 提供ESB 应用mule源代码
💻 VM
字号:
/* * $Id: TransactedMessageReceiver.vm 11079 2008-02-27 15:52:01Z tcarlson $ * -------------------------------------------------------------------------------------- * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com * * The software in this package is published under the terms of the CPAL v1.0 * license, a copy of which has been included with this distribution in the * LICENSE.txt file. */package org.mule.transport.${TransportNameLower};import org.mule.DefaultMuleMessage;import org.mule.api.endpoint.InboundEndpoint;import org.mule.api.lifecycle.CreateException;import org.mule.api.service.Service;import org.mule.api.transport.Connector;import org.mule.api.transport.MessageAdapter;import org.mule.transport.ConnectException;import org.mule.transport.TransactedPollingMessageReceiver;import java.util.List;/** * <code>${TransportName}</code> Todo Document * */public class ${TransportName}TransactedMessageReceiver extends TransactedPollingMessageReceiver{    /* For general guidelines on writing transports see       http://mule.mulesource.org/display/MULE/Writing+Transports */    public ${TransportName}TransactedMessageReceiver(Connector connector,                                          Service service,                                          final InboundEndpoint endpoint) throws CreateException    {        super(connector, service, endpoint);    }    protected List getMessages() throws Exception    {        /* IMPLEMENTATION NOTE: You can just return a single message in a list           or return a batch of messages to be processed. It's always           recommend to process single messages to start with and then           experiment with batching */        // TODO Consume one or more messages from the underlying technology        // This method is executed within a transaction template so all        // operations will be part of the transation        throw new UnsupportedOperationException("getMessages");    }    protected void processMessage(Object message) throws Exception    {        // TODO Process the current message.  The object will be of the same        // type returned in the List from getMessages()        // Here is how to pass the message to Mule.  Most MessageReceivers        // will need to do nothing more than this        MessageAdapter adapter = connector.getMessageAdapter(message);        routeMessage(new DefaultMuleMessage(adapter), endpoint.isSynchronous());    }    public void doConnect() throws ConnectException    {        /* IMPLEMENTATION NOTE: Should make a connection to the underlying           transport i.e. connect to a socket or register a soap service. When           there is no connection to be made this method should be used to           chack that resources are available. For example the           FileMessageReceiver checks that the directories it will be using           are available and readable. The MessageReceiver should remain in a           'stopped' state even after the doConnect() method is called. This           means that a connection has been made but no events will be           received until the start() method is called. Calling start() on the           MessageReceiver will call doConnect() if the receiver hasn't           connected. */        /* IMPLEMENTATION NOTE: If you need to spawn any threads such as           worker threads for this receiver you can Schedule a worker thread           with the work manager i.e.             getWorkManager().scheduleWork(worker, WorkManager.INDEFINITE, null, null);           Where 'worker' implemments javax.resource.spi.work.Work */        /* IMPLEMENTATION NOTE: When throwing an exception from this method           you need to throw a ConnectException that accepts a Message, a           cause exception and a reference to this MessageReceiver i.e.             throw new ConnectException(new Message(Messages.FAILED_TO_SCHEDULE_WORK), e, this);        */        // TODO the code necessay to Connect to the underlying resource    }    public void doDisconnect() throws ConnectException    {        /* IMPLEMENTATION NOTE: Disconnects and tidies up any rources allocted           using the doConnect() method. This method should return the           MessageReceiver into a disconnected state so that it can be           connected again using the doConnect() method. */        // TODO release any resources    }    public void doStart()    {        // Optional; does not need to be implemented. Delete if not required        /* IMPLEMENTATION NOTE: Should perform any actions necessary to enable           the reciever to start reciving events. This is different to the           doConnect() method which actually makes a connection to the           transport, but leaves the MessageReceiver in a stopped state. For           polling-based MessageReceivers the start() method simply starts the           polling thread, for the Axis Message receiver the start method on           the SOAPService is called. What action is performed here depends on           the transport being used. Most of the time a custom provider           doesn't need to override this method. */    }    public void doStop()    {        // Optional; does not need to be implemented. Delete if not required        /* IMPLEMENTATION NOTE: Should perform any actions necessary to stop           the reciever from receiving events. */    }    public void doDispose()    {        // Optional; does not need to be implemented. Delete if not required        /* IMPLEMENTATION NOTE: Is called when the Conector is being dispoed           and should clean up any resources. The doStop() and doDisconnect()           methods will be called implicitly when this method is called. */    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -