当前位置: 首页>>代码示例>>Java>>正文


Java JmsTemplate.send方法代码示例

本文整理汇总了Java中org.springframework.jms.core.JmsTemplate.send方法的典型用法代码示例。如果您正苦于以下问题:Java JmsTemplate.send方法的具体用法?Java JmsTemplate.send怎么用?Java JmsTemplate.send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.jms.core.JmsTemplate的用法示例。


在下文中一共展示了JmsTemplate.send方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateFailOnUnsupportedMessageTypeOverJNDI

import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
public void validateFailOnUnsupportedMessageTypeOverJNDI() throws Exception {
    final String destinationName = "testQueue";
    JmsTemplate jmsTemplate = CommonTest.buildJmsJndiTemplateForDestination(false);

    jmsTemplate.send(destinationName, new MessageCreator() {
        @Override
        public Message createMessage(Session session) throws JMSException {
            return session.createObjectMessage();
        }
    });

    JMSConsumer consumer = new JMSConsumer(jmsTemplate, mock(ComponentLog.class));
    try {
        consumer.consume(destinationName, new ConsumerCallback() {
            @Override
            public void accept(JMSResponse response) {
                // noop
            }
        });
    } finally {
        ((CachingConnectionFactory) jmsTemplate.getConnectionFactory()).destroy();
    }
}
 
开发者ID:lsac,项目名称:nifi-jms-jndi,代码行数:24,代码来源:JMSPublisherConsumerTest.java

示例2: validateFailOnUnsupportedMessageType

import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
/**
 * At the moment the only two supported message types are TextMessage and
 * BytesMessage which is sufficient for the type if JMS use cases NiFi is
 * used. The may change to the point where all message types are supported
 * at which point this test will no be longer required.
 */
@Test(expected = IllegalStateException.class)
public void validateFailOnUnsupportedMessageType() throws Exception {
    final String destinationName = "testQueue";
    JmsTemplate jmsTemplate = CommonTest.buildJmsTemplateForDestination(false);

    jmsTemplate.send(destinationName, new MessageCreator() {
        @Override
        public Message createMessage(Session session) throws JMSException {
            return session.createObjectMessage();
        }
    });

    JMSConsumer consumer = new JMSConsumer(jmsTemplate, mock(ComponentLog.class));
    try {
        consumer.consume(destinationName, new ConsumerCallback() {
            @Override
            public void accept(JMSResponse response) {
                // noop
            }
        });
    } finally {
        ((CachingConnectionFactory) jmsTemplate.getConnectionFactory()).destroy();
    }
}
 
开发者ID:SolaceLabs,项目名称:solace-integration-guides,代码行数:31,代码来源:JMSPublisherConsumerTest.java

示例3: sendMessageDelay

import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
/**
 * 延迟发送对象消息
 * @param jmsTemplate
 * @param destination
 * @param objectMessage
 * @param delay
 */
public static void sendMessageDelay(JmsTemplate jmsTemplate, Destination destination, final Serializable objectMessage, final long delay) {
    jmsTemplate.send(destination, new MessageCreator() {
        @Override
        public Message createMessage(Session session) throws JMSException {
            ObjectMessage om = session.createObjectMessage(objectMessage);
            om.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, delay);
            om.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_PERIOD, 1 * 1000);
            om.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_REPEAT, 1);
            return om;
        }
    });
}
 
开发者ID:ChangyiHuang,项目名称:shuzheng,代码行数:20,代码来源:JmsUtil.java

示例4: send

import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
/**
 * 发送数据
 * @param jmsTemplate
 * @param queue
 */
public void send(JmsTemplate jmsTemplate,ActiveMQDestination queue){
    for(int i=0;i<10;i++){
        final int k=i;
        //发送消息
        jmsTemplate.send(queue, new MessageCreator() {
            @Override
            public Message createMessage(Session session) throws JMSException {
                return session.createTextMessage("hello!this is number:"+k);
            }
        });
    }

}
 
开发者ID:tomoncle,项目名称:JavaStudy,代码行数:19,代码来源:App.java

示例5: sendMessage

import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
/**
 * 发送文本消息
 * @param jmsTemplate
 * @param destination
 * @param textMessage
 */
public static void sendMessage(JmsTemplate jmsTemplate, Destination destination, final String textMessage) {
    jmsTemplate.send(destination, new MessageCreator() {
        @Override
        public Message createMessage(Session session) throws JMSException {
            return session.createTextMessage(textMessage);
        }
    });
}
 
开发者ID:ChangyiHuang,项目名称:shuzheng,代码行数:15,代码来源:JmsUtil.java

示例6: validateConsumeWithCustomHeadersAndProperties

import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
@Test
public void validateConsumeWithCustomHeadersAndProperties() throws Exception {
    final String destinationName = "testQueue";
    JmsTemplate jmsTemplate = CommonTest.buildJmsTemplateForDestination(false);

    jmsTemplate.send(destinationName, new MessageCreator() {
        @Override
        public Message createMessage(Session session) throws JMSException {
            TextMessage message = session.createTextMessage("hello from the other side");
            message.setStringProperty("foo", "foo");
            message.setBooleanProperty("bar", false);
            message.setJMSReplyTo(session.createQueue("fooQueue"));
            return message;
        }
    });

    JMSConsumer consumer = new JMSConsumer(jmsTemplate, mock(ComponentLog.class));
    final AtomicBoolean callbackInvoked = new AtomicBoolean();
    consumer.consume(destinationName, new ConsumerCallback() {
        @Override
        public void accept(JMSResponse response) {
            callbackInvoked.set(true);
            assertEquals("hello from the other side", new String(response.getMessageBody()));
            assertEquals("fooQueue", response.getMessageHeaders().get(JmsHeaders.REPLY_TO));
            assertEquals("foo", response.getMessageProperties().get("foo"));
            assertEquals("false", response.getMessageProperties().get("bar"));
        }
    });
    assertTrue(callbackInvoked.get());

    ((CachingConnectionFactory) jmsTemplate.getConnectionFactory()).destroy();
}
 
开发者ID:lsac,项目名称:nifi-jms-jndi,代码行数:33,代码来源:JMSPublisherConsumerTest.java

示例7: sendMessageDelay

import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
/**
 * 延迟发送对象消息
 * @param jmsTemplate
 * @param destination
 * @param objectMessage
 * @param delay
 */
public static void sendMessageDelay(JmsTemplate jmsTemplate, Destination destination, final Serializable objectMessage, final long delay) {
    jmsTemplate.send(destination, new MessageCreator() {
        public Message createMessage(Session session) throws JMSException {
            ObjectMessage om = session.createObjectMessage(objectMessage);
            om.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, delay);
            om.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_PERIOD, 1 * 1000);
            om.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_REPEAT, 1);
            return om;
        }
    });
}
 
开发者ID:lgpzjp,项目名称:rure,代码行数:19,代码来源:JmsUtil.java

示例8: sendMessage

import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
/**
 * 发送文本消息
 * @param jmsTemplate
 * @param destination
 * @param textMessage
 */
public static void sendMessage(JmsTemplate jmsTemplate, Destination destination, final String textMessage) {
    jmsTemplate.send(destination, new MessageCreator() {
        public Message createMessage(Session session) throws JMSException {
            return session.createTextMessage(textMessage);
        }
    });
}
 
开发者ID:youngMen1,项目名称:-Spring-SpringMVC-Mybatis-,代码行数:14,代码来源:JmsUtil.java

示例9: validateConsumeWithCustomHeadersAndPropertiesOverJNDI

import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
@Test
public void validateConsumeWithCustomHeadersAndPropertiesOverJNDI() throws Exception {
    final String destinationName = "testQueue";
    JmsTemplate jmsTemplate = CommonTest.buildJmsJndiTemplateForDestination(false);

    jmsTemplate.send(destinationName, new MessageCreator() {
        @Override
        public Message createMessage(Session session) throws JMSException {
            TextMessage message = session.createTextMessage("hello from the other side");
            message.setStringProperty("foo", "foo");
            message.setBooleanProperty("bar", false);
            message.setJMSReplyTo(session.createQueue("fooQueue"));
            return message;
        }
    });

    JMSConsumer consumer = new JMSConsumer(jmsTemplate, mock(ComponentLog.class));
    final AtomicBoolean callbackInvoked = new AtomicBoolean();
    consumer.consume(destinationName, new ConsumerCallback() {
        @Override
        public void accept(JMSResponse response) {
            callbackInvoked.set(true);
            assertEquals("hello from the other side", new String(response.getMessageBody()));
            assertEquals("fooQueue", response.getMessageHeaders().get(JmsHeaders.REPLY_TO));
            assertEquals("foo", response.getMessageProperties().get("foo"));
            assertEquals("false", response.getMessageProperties().get("bar"));
        }
    });
    assertTrue(callbackInvoked.get());

    ((CachingConnectionFactory) jmsTemplate.getConnectionFactory()).destroy();
}
 
开发者ID:SolaceLabs,项目名称:solace-integration-guides,代码行数:33,代码来源:JMSPublisherConsumerTest.java

示例10: sendMessage

import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
/**
 * 发送对象消息
 * @param jmsTemplate
 * @param destination
 * @param objectMessage
 */
public static void sendMessage(JmsTemplate jmsTemplate, Destination destination, final Serializable objectMessage) {
    jmsTemplate.send(destination, new MessageCreator() {
        public Message createMessage(Session session) throws JMSException {
            return session.createObjectMessage(objectMessage);
        }
    });
}
 
开发者ID:lgpzjp,项目名称:rure,代码行数:14,代码来源:JmsUtil.java


注:本文中的org.springframework.jms.core.JmsTemplate.send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。