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


Java ScheduledMessage类代码示例

本文整理汇总了Java中org.apache.activemq.ScheduledMessage的典型用法代码示例。如果您正苦于以下问题:Java ScheduledMessage类的具体用法?Java ScheduledMessage怎么用?Java ScheduledMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: sendMessage

import org.apache.activemq.ScheduledMessage; //导入依赖的package包/类
public void sendMessage() {
	jmsTemplate.send(notifyTopic, new MessageCreator() {
		@Override
		public Message createMessage(Session session) throws JMSException {

			MapMessage message = session.createMapMessage();
			
			int delay=10*1000;
			System.out.println("生产消消息");
			message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY,	 delay);
			message.setStringProperty("objectType", "user");

			return message;
		}
	});
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:17,代码来源:AdvancedNotifyMessageProducer.java

示例2: fromHeaders

import org.apache.activemq.ScheduledMessage; //导入依赖的package包/类
/**
 * {@inheritDoc}. Additionally sets <code>AMQ_SCHEDULED_DELAY</code> using
 * <code>MotechEventConfig</code> variables.
 */
@Override
public void fromHeaders(MessageHeaders messageHeaders, Message message) {
    super.fromHeaders(messageHeaders, message);
    try {
        MotechEvent motechEvent = (MotechEvent) ((ActiveMQObjectMessage) message).getObject();

        if (motechEvent.isInvalid()) {
            long redeliveryCount = motechEvent.getMessageRedeliveryCount();
            Double delay = motechEventConfig.getMessageRedeliveryDelay() * MILLIS_PER_SEC *
                    ((Math.pow(2, redeliveryCount - 1)));
            LOGGER.debug("Redelivering " + motechEvent + " after " + delay + " millis.");
            message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, delay.longValue());
        }
    } catch (JMSException e) {
        LOGGER.error("Failed to set header", e);
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:22,代码来源:MotechEventHeaderMapper.java

示例3: testCronScheduleWithTtlSet

import org.apache.activemq.ScheduledMessage; //导入依赖的package包/类
@Test
public void testCronScheduleWithTtlSet() throws Exception {

   Connection connection = createConnection();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageConsumer consumer = session.createConsumer(destination);
   connection.start();

   MessageProducer producer = session.createProducer(destination);
   producer.setTimeToLive(TimeUnit.MINUTES.toMillis(1));
   TextMessage message = session.createTextMessage("test msg ");
   message.setStringProperty(ScheduledMessage.AMQ_SCHEDULED_CRON, "* * * * *");

   producer.send(message);
   producer.close();

   Thread.sleep(TimeUnit.MINUTES.toMillis(2));

   assertNotNull(consumer.receiveNoWait());
   assertNull(consumer.receiveNoWait());
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:JmsCronSchedulerTest.java

示例4: testRemoveNotScheduled

import org.apache.activemq.ScheduledMessage; //导入依赖的package包/类
@Test
public void testRemoveNotScheduled() throws Exception {
   Connection connection = createConnection();

   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

   // Create the Browse Destination and the Reply To location
   Destination management = session.createTopic(ScheduledMessage.AMQ_SCHEDULER_MANAGEMENT_DESTINATION);

   MessageProducer producer = session.createProducer(management);

   try {

      // Send the remove request
      Message remove = session.createMessage();
      remove.setStringProperty(ScheduledMessage.AMQ_SCHEDULER_ACTION, ScheduledMessage.AMQ_SCHEDULER_ACTION_REMOVEALL);
      remove.setStringProperty(ScheduledMessage.AMQ_SCHEDULED_ID, new IdGenerator().generateId());
      producer.send(remove);
   } catch (Exception e) {
      fail("Caught unexpected exception during remove of unscheduled message.");
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:23,代码来源:JobSchedulerManagementTest.java

示例5: testSchedule

import org.apache.activemq.ScheduledMessage; //导入依赖的package包/类
public void testSchedule() throws Exception {

      Connection connection = createConnection();
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

      connection.start();
      final long time = 1000;

      ProducerThread producer = new ProducerThread(session, destination) {
         @Override
         protected Message createMessage(int i) throws Exception {
            Message message = super.createMessage(i);
            message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, time);
            return message;
         }
      };

      producer.setMessageCount(200);
      producer.setDaemon(true);

      producer.start();

      Thread.sleep(5000);
   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:25,代码来源:JobSchedulerBrokerShutdownTest.java

示例6: offer

import org.apache.activemq.ScheduledMessage; //导入依赖的package包/类
@Override
public boolean offer(T event) throws IvoryException {
	Session session;
	try {
		session = getSession();
		TextMessage msg = session.createTextMessage(event.toString());
		msg.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY,
				event.getDelay(TimeUnit.MILLISECONDS));
		msg.setStringProperty("TYPE", event.getType().name());
		producer.send(msg);
		LOG.debug("Enqueued Message:" + event.toString() + "with delay "
				+ event.getDelay(TimeUnit.MILLISECONDS) + " milli sec");
		return true;
	} catch (Exception e) {
		LOG.error("Unable to offer event:" + event + " to activeMqueue", e);
		throw new IvoryException("Unable to offer event:" + event + " to activeMqueue", e);
	}
}
 
开发者ID:sriksun,项目名称:ivry-security,代码行数:19,代码来源:ActiveMQueue.java

示例7: offer

import org.apache.activemq.ScheduledMessage; //导入依赖的package包/类
@Override
public boolean offer(T event) throws FalconException {
    Session session;
    try {
        session = getSession();
        TextMessage msg = session.createTextMessage(event.toString());
        msg.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY,
                event.getDelay(TimeUnit.MILLISECONDS));
        msg.setStringProperty("TYPE", event.getType().name());
        producer.send(msg);
        LOG.debug("Enqueued Message:" + event.toString() + "with delay "
                + event.getDelay(TimeUnit.MILLISECONDS) + " milli sec");
        return true;
    } catch (Exception e) {
        LOG.error("Unable to offer event:" + event + " to activeMqueue", e);
        throw new FalconException("Unable to offer event:" + event + " to activeMqueue", e);
    }
}
 
开发者ID:shaikidris,项目名称:incubator-falcon,代码行数:19,代码来源:ActiveMQueue.java

示例8: sendMessageDelay

import org.apache.activemq.ScheduledMessage; //导入依赖的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:youngMen1,项目名称:-Spring-SpringMVC-Mybatis-,代码行数:19,代码来源:JmsUtil.java

示例9: send

import org.apache.activemq.ScheduledMessage; //导入依赖的package包/类
/**
 * 发送延迟消息
 * @param msg
 * @param delay
 */
public void send(String msg, long delay) {
    _log.info("发送MQ延时消息:msg={},delay={}", msg, delay);
    jmsTemplate.send(this.payNotifyQueue, new MessageCreator() {
        public Message createMessage(Session session) throws JMSException {
            TextMessage tm = session.createTextMessage(msg);
            tm.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, delay);
            tm.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_PERIOD, 1*1000);
            tm.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_REPEAT, 1);
            return tm;
        }
    });
}
 
开发者ID:ywtnhm,项目名称:pay-xxpay-master,代码行数:18,代码来源:Mq4PayNotify.java

示例10: send

import org.apache.activemq.ScheduledMessage; //导入依赖的package包/类
public void send() {
	template.send(this.destination, new MessageCreator() {
		@Override
		public Message createMessage(Session session) throws JMSException {
			TextMessage message=session.createTextMessage();
			System.out.println("发出消息,延时10秒.");
			String msgId=message.getJMSMessageID();
			System.out.println("msgId:"+msgId);
			message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, 20*1000);
			message.setStringProperty("content", "内容content...");
			return message;
		}
	});
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:15,代码来源:InvokeMessageProducer.java

示例11: toMessage

import org.apache.activemq.ScheduledMessage; //导入依赖的package包/类
public Message toMessage(Object obj, Session session) throws JMSException,
			MessageConversionException {

		if (obj instanceof InvokeMessage) {
			ActiveMQObjectMessage objMsg = (ActiveMQObjectMessage) session
					.createObjectMessage();
			long delay=5*1000;
        	System.out.println("延时:"+delay/1000+"秒");
        	System.out.println("msgId:"+objMsg.getJMSMessageID());
        	objMsg.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, delay);
//        	objMsg.setExpiration(2000);
        	
			Map<String, byte[]> map = new HashMap<String, byte[]>();
			try {
				ByteArrayOutputStream bos = new ByteArrayOutputStream();
				ObjectOutputStream oos = new ObjectOutputStream(bos);
				oos.writeObject(obj);
				map.put("InvokeMessage", bos.toByteArray());
			} catch (IOException e) {
				e.printStackTrace();
			}
			objMsg.setObjectProperty("Map", map);
			return objMsg;
		} else {
			throw new JMSException("Object:[" + obj + "] is not InvokeMessage");
		}
	}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:28,代码来源:InvokeMessageConverter.java

示例12: send

import org.apache.activemq.ScheduledMessage; //导入依赖的package包/类
public void send(){
	jmsTemplate.send(notifyQueue,new MessageCreator() {
		@Override
		public Message createMessage(Session session) throws JMSException {
			TextMessage	message=session.createTextMessage("textMsg....柯远");
			message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, 65*1000);
			System.out.println("等65秒后再发");
			return message;
		}
	});
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:12,代码来源:NotifyMessageProducer.java

示例13: send

import org.apache.activemq.ScheduledMessage; //导入依赖的package包/类
/**
 * 发送延迟消息
 * @param msg
 * @param delay
 */
public void send(String msg, long delay) {
    _log.info("发送MQ延时消息:msg={},delay={}", msg, delay);
    jmsTemplate.send(this.transNotifyQueue, new MessageCreator() {
        public Message createMessage(Session session) throws JMSException {
            TextMessage tm = session.createTextMessage(msg);
            tm.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, delay);
            tm.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_PERIOD, 1*1000);
            tm.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_REPEAT, 1);
            return tm;
        }
    });
}
 
开发者ID:jmdhappy,项目名称:xxpay-master,代码行数:18,代码来源:Mq4TransNotify.java

示例14: send

import org.apache.activemq.ScheduledMessage; //导入依赖的package包/类
/**
 * 发送延迟消息
 * @param msg
 * @param delay
 */
public void send(Queue queue, String msg, long delay) {
    _log.info("发送MQ延时消息:msg={},delay={}", msg, delay);
    jmsTemplate.send(queue, new MessageCreator() {
        public Message createMessage(Session session) throws JMSException {
            TextMessage tm = session.createTextMessage(msg);
            tm.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, delay);
            tm.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_PERIOD, 1*1000);
            tm.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_REPEAT, 1);
            return tm;
        }
    });
}
 
开发者ID:jmdhappy,项目名称:xxpay-master,代码行数:18,代码来源:Mq4MchNotify.java

示例15: send

import org.apache.activemq.ScheduledMessage; //导入依赖的package包/类
/**
 * 发送延迟消息
 * @param msg
 * @param delay
 */
public void send(String msg, long delay) {
    _log.info("发送MQ延时消息:msg={},delay={}", msg, delay);
    jmsTemplate.send(this.refundNotifyQueue, new MessageCreator() {
        public Message createMessage(Session session) throws JMSException {
            TextMessage tm = session.createTextMessage(msg);
            tm.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, delay);
            tm.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_PERIOD, 1*1000);
            tm.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_REPEAT, 1);
            return tm;
        }
    });
}
 
开发者ID:jmdhappy,项目名称:xxpay-master,代码行数:18,代码来源:Mq4RefundNotify.java


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