不使用XML配置的ActiveMQ桥连接器到WebSphereMQ [英] ActiveMQ bridge connector to WebSphereMQ without using XML config

查看:131
本文介绍了不使用XML配置的ActiveMQ桥连接器到WebSphereMQ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个代理来代理ActiveMQ和嵌入式代理中的WebSphere MQ之间的连接。我知道activemq中存在网络连接器(代理对代理),但是我不知道如何配置它以连接到WebSphere MQ。在Web上进行搜索时,我发现了一些与XML配置有关的不同方法,并且我发现所使用的XML标记并不引用网络连接器,而是引用< jmsBridgeConnectors> ,所以我使用Java代码对这种桥连接器进行了研究,但找不到能为我提供帮助的东西。

I want to create a broker to broker connection between ActiveMQ and WebSphere MQ in an embedded broker. I know that exists the network connector in activemq to do that (broker-to-broker), but I don't know how to configure it to connect to WebSphere MQ. Doing a search in the web I found some different ways to do with XML configuration and I noticed that the XML tags used does not refer the network connector, but refers a <jmsBridgeConnectors>, so I do a research about this bridge connector by using java code but I wasn't able to find something that points me about how to do that.

对于嵌入式代理,是否有明确的方法通过使用Java代码而不是XML配置来将ActiveMQ中的桥连接器配置为WebSphere MQ?

Is there an explicit way to configure a bridge connector in ActiveMQ to a WebSphere MQ, for an embedded broker by using java code instead to use the XML configuration?

我知道可以通过使用XML配置来实现,但是,如果我要实现嵌入式代理(如前所述),并且我想使用用Java代码连接到WebSphere MQ的桥连接器,ActiveMQ是否在API上提供类或接口来做到这一点?

I know that is possible by using XML configuration, but, what if I am implementing an embedded broker (as I've mentioned before), and I want to configure the broker instance with a bridge connector to WebSphere MQ with java code, Does ActiveMQ provide a Class or Interface on the API to do this?

这是我为连接两个activemq代理而做的

This is what I have done to connect two activemq brokers

try {
        getBroker().addConnector("tcp://localhost:61616");
        getBroker().addNetworkConnector("static:(tcp://remotBroker:61616)");
    } catch (Exception e) {
        logger.error("Unexpected ERROR, connection lost.");
        e.printStackTrace();
    }

一个TransportConnector监听端口61616,一个Network Connector建立与我的连接本地代理到remoteBroker,这两个代理都是activemq的
实例。现在,我希望使用Java代码而不是XML从ActiveMQ本地代理到WebSphere MQ代理的连接。

One TransportConnector to listen in port 61616 and one Network connector to establish connection from my local broker to the remoteBroker, both brokers are instances of activemq. Now I want a connection from my ActiveMQ local broker to WebSphere MQ broker using java code, no XML.

推荐答案

这很简单。
以下示例将把ActiveMQ队列QUEUE42上的所有消息发送到远程WebSphere MQ代理。更改连接设置。

It's pretty simple. The following example will send all messages on the ActiveMQ queue QUEUE42 to a remote WebSphere MQ broker. Change connection settings.

这要求您在类路径上有一些WMQ库:com.ibm.mq.jar和com.ibm.mqjms.jar(至少) 。诀窍是简单地创建一个带有QueueConnectionFactory的JmsQueueConnector(到WMQ)以及所需的任何入站/出站桥。桥只是将要复制的队列名称。

This requires you to have some WMQ libs on your classpath: com.ibm.mq.jar and com.ibm.mqjms.jar (at least). The trick is to simply create a JmsQueueConnector with a QueueConnectionFactory (to WMQ) and whatever inbound/outbound bridges you want. The bridges are simply queue names that will be copied.

    BrokerService broker = new BrokerService();
    broker.setBrokerName("amqbroker");
    broker.setPersistent(false);
    broker.setTransportConnectorURIs(new String[] {"tcp://localhost:61616"});

    // setup bridge
    JmsQueueConnector qCon = new JmsQueueConnector();

    JmsFactoryFactory ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER);
    JmsQueueConnectionFactory cf = ff.createQueueConnectionFactory();
    cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, "192.168.13.151");
    cf.setIntProperty(WMQConstants.WMQ_PORT, 1414);
    cf.setStringProperty(WMQConstants.WMQ_CHANNEL, "SYSTEM.DEF.SVRCONN");
    cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
    cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, "SUPERHERO");

    qCon.setOutboundQueueConnectionFactory(cf);
    OutboundQueueBridge outBridge1 = new OutboundQueueBridge("QUEUE42");
    qCon.setOutboundQueueBridges(new OutboundQueueBridge[] {outBridge1});
    broker.setJmsBridgeConnectors(new JmsConnector[] {qCon});
    broker.start();

这篇关于不使用XML配置的ActiveMQ桥连接器到WebSphereMQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆