【问题标题】:Middleware application in distributed environment分布式环境中的中间件应用
【发布时间】:2012-10-19 18:55:18
【问题描述】:

我想开发一个应用程序,它将数据从一个应用程序传输到另一个应用程序。现在关键是我的一个应用程序是在 .Net 框架中,而另一个是在 Spring 框架 (Java) 中实现的。

哪种编程技术最适合这种环境?
是的!数据将非常庞大,它将包括 BLOB。而且转账的时候有断网的可能,所以一定是交易之类的;因为我当然不想丢失数据。

您如何看待 XML over http?

请建议我应该实施哪种应用程序来传输数据。

【问题讨论】:

    标签: c# java .net spring-mvc middleware


    【解决方案1】:

    使用 Java,JMS 提供了一种将应用程序与提供数据的传输层分离的方法。通过使用所需提供者的 JNDI 信息,可以使用相同的 Java 类与不同的 JMS 提供者进行通信。这些类首先使用连接工厂连接到队列或主题,然后使用填充和发送或发布消息。在接收端,客户端然后接收或订阅消息。

    我使用过SonicMQ messaging system,而他们的Java Message Services 非常稳定...您可以查看一个关于我如何使用它的小示例here,还有一个.Net implementation

    编码可能非常简单:

    /**
     * 
     * This file is part of Jms.publisher sample.
     * 
     *  Jms.publisher is free software: you can redistribute it and/or modify
     *  it under the terms of the GNU General Public License as published by
     *  the Free Software Foundation, either version 3 of the License, or
     *  (at your option) any later version.
     * 
     *  Jms.publisher is distributed in the hope that it will be useful,
     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     *  GNU General Public License for more details.
     * 
     *  You should have received a copy of the GNU General Public License
     *  along with Jms.publisher.  If not, see <http://www.gnu.org/licenses/>.
     *  
     * 
     * AccessManager.Java 
     * Create by Iván Jaimes on 03/09/2012
     * 
     */
    package sonic;
    
    import javax.jms.JMSException;
    import javax.jms.Session;
    import javax.jms.TextMessage;
    import javax.jms.TopicConnection;
    import javax.jms.TopicPublisher;
    import javax.jms.TopicSession;
    import javax.jms.TopicConnectionFactory;
    
    import config.ConnectionInfo;
    
    public class AccessManager 
    {
        private TopicConnection connection = null;
        private TopicSession session = null;
        private TopicPublisher topicPublisher = null;    
        private TopicConnectionFactory connectionFactory = null;
        private ConnectionInfo info = null;
    
        public AccessManager(ConnectionInfo connectionInfo) throws JMSException
        {
            info = connectionInfo;
        }
    
        public final void connect() throws JMSException
        {
            connectionFactory = new progress.message.jclient.TopicConnectionFactory(info.getSonicAddress());
            connection = connectionFactory.createTopicConnection(info.getUserName(), info.getPassword());
            connection.start();
            session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
            topicPublisher = session.createPublisher(info.getTopic());
            assert (isConnected());
        }
    
        public void send(String text) throws JMSException  
        {
            TextMessage message = session.createTextMessage(text); // send method
            topicPublisher.publish(message);
        }
        /**
         * Disconnect.
         * @throws JMSException 
         */
        public final void disconnect() throws JMSException 
        {
            if (topicPublisher != null) 
            {
                topicPublisher.close();
                session.close();
                connection.close();
            }
    
            connection = null;
            session = null;
        }
    
        /**
         * Checks if is connected.
         * 
         * @return true, if is connected
         */
        public final boolean isConnected() {
            if (session != null) {
                return true;
            }
            return false;
        }
    }
    

    还有更多关于它的资源:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-05
      • 2016-06-04
      • 2012-08-04
      • 2018-10-29
      • 2011-08-12
      • 1970-01-01
      • 2014-11-24
      • 1970-01-01
      相关资源
      最近更新 更多