【问题标题】:Calling Camel JMS-Endpoint without using camelproxy在不使用 camelproxy 的情况下调用 Camel JMS-Endpoint
【发布时间】:2013-02-03 02:56:48
【问题描述】:

我已经创建了一个 jms 端点,并且能够从客户端宽度调用它,即 spring xml 文件中的 camel:proxy。 现在我希望能够在不使用 Spring/Camel 代理的情况下直接调用 JMS 端点。我想通过 URL 调用它。

我该怎么做

谢谢

【问题讨论】:

    标签: java jms apache-camel spring-jms


    【解决方案1】:

    骆驼队列可以通过以下方式发布到

    public DirectJMSRemotingClient() throws JMSException {
        factory = new ActiveMQConnectionFactory(brokerURL);
        connection = factory.createConnection();
        connection.start();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination destination = session.createQueue("queueName");
        producer = session.createProducer(destination);
    }
    
    public void sendMessage() throws JMSException {
    
        TextMessage myTextMsg = session.createTextMessage();
    
        myTextMsg.setText("Hello World");
        System.out.println("Sending Message: " + myTextMsg.getText());
        producer.send(myTextMsg);
    }
    
    public static void main(String[] args) throws Exception {
        DirectJMSRemotingClient client = new DirectJMSRemotingClient();
        client.sendMessage();
    }    
    

    而且路线可以像这样在骆驼中定义

        <route>
            <from uri="jms:queue:queueName" />
            <setExchangePattern pattern="InOut" />
            <to uri="seda:camel-handler" />
        </route>
    

    【讨论】:

      【解决方案2】:

      您可以使用 Camel 中的 ProducerTemplate API 向任何类型的 Camel 端点/组件发送消息。

      详情请见:http://camel.apache.org/producertemplate.html

      【讨论】:

        猜你喜欢
        • 2017-04-15
        • 2019-11-08
        • 2014-08-21
        • 1970-01-01
        • 2013-06-13
        • 2016-11-27
        • 1970-01-01
        • 1970-01-01
        • 2012-12-24
        相关资源
        最近更新 更多