简体   繁体   English

分布式环境中的中间件应用

[英]Middleware application in distributed environment

I want to develop an application which will transfer data from one application to another application. 我想开发一个应用程序,它将数据从一个应用程序传输到另一个应用程序。 Now the kick here is that one of my application is in .Net framework while the other is implemented in Spring framework (Java). 现在的问题是,我的一个应用程序在.Net框架中,而另一个应用程序在Spring框架(Java)中实现。

Which programming technique would best suit this sort of environment? 哪种编程技术最适合此类环境?
And Yes ! 是的 ! data will be quite heavy, it will include BLOBs. 数据将非常繁重,其中将包括BLOB。 Moreover, there are chances of network break during transfer, therefore, it has to be something like transactions; 而且,在传输过程中可能会出现网络中断的情况,因此,它必须类似于事务处理。 as I certainly don't want to lose data. 因为我当然不想丢失数据。

What do you think about XML over http? 您如何看待基于HTTP的XML?

Please suggest what sort of application should i be implementing to transfer data. 请建议我应该实施哪种应用程序来传输数据。

Using Java, JMS provides a way of separating the application from the transport layer of providing data. 使用Java,JMS提供了一种将应用程序与提供数据的传输层分离的方法。 The same Java classes can be used to communicate with different JMS providers by using the JNDI information for the desired provider. 通过使用所需提供者的JNDI信息,可以使用相同的Java类与不同的JMS提供者进行通信。 The classes first use a connection factory to connect to the queue or topic, and then use populate and send or publish the messages. 这些类首先使用连接工厂连接到队列或主题,然后使用填充以及发送或发布消息。 On the receiving side, the clients then receive or subscribe to the messages. 然后,在接收方,客户端接收或订阅消息。

I've used SonicMQ messaging system and thier Java Message Services is very stable... you can view a little sample about how i'm using it here and there is a .Net implementation 我已经使用了SonicMQ消息传递系统,并且Java消息服务非常稳定...您可以在此处查看有关我如何使用它的一些示例,并且有一个.Net实现

The codification could be very simple: 编码可能非常简单:

/**
 * 
 * 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;
    }
}

There are more resources about it: 关于它的更多资源:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM