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


Java ActiveMQObjectMessage类代码示例

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


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

示例1: getTypeName

import org.apache.activemq.command.ActiveMQObjectMessage; //导入依赖的package包/类
@Override
protected String getTypeName() {
    return ActiveMQObjectMessage.class.getName();
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:5,代码来源:OpenTypeSupport.java

示例2: fromHeaders

import org.apache.activemq.command.ActiveMQObjectMessage; //导入依赖的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: testObjectMessageCompression

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

   MessageConsumer consumer1 = remoteSession.createConsumer(included);
   MessageProducer producer = localSession.createProducer(included);
   producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

   waitForConsumerRegistration(localBroker, 1, included);

   StringBuilder payload = new StringBuilder("test-");
   for (int i = 0; i < 100; ++i) {
      payload.append(UUID.randomUUID().toString());
   }

   Message test = localSession.createObjectMessage(payload.toString());
   producer.send(test);
   Message msg = consumer1.receive(RECEIVE_TIMEOUT_MILLS);
   assertNotNull(msg);
   ActiveMQObjectMessage message = (ActiveMQObjectMessage) msg;
   assertTrue(message.isCompressed());
   assertEquals(payload.toString(), message.getObject());
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:23,代码来源:CompressionOverNetworkTest.java

示例4: getMessagesFromBroker

import org.apache.activemq.command.ActiveMQObjectMessage; //导入依赖的package包/类
protected List<Object[]> getMessagesFromBroker() throws JMSException {
    List<Object[]> messages = new ArrayList<Object[]>();
    Message message = new ActiveMQMessage();
    while (message != null) {
        message = messageConsumer.receive(1000);
        if (message == null) {
            break;
        }

        Serializable obj = ((ActiveMQObjectMessage)message).getObject();
        if (obj != null && obj instanceof Object[]) {
            messages.add((Object[])obj);
        }
    }

    return messages;
}
 
开发者ID:garethahealy,项目名称:jboss-fuse-examples,代码行数:18,代码来源:BaseBroker.java

示例5: onMessage

import org.apache.activemq.command.ActiveMQObjectMessage; //导入依赖的package包/类
@Override
public void onMessage(Message message) {
    //TODO add transactional logic here with txn manager

    if (message instanceof ObjectMessage) {
        ServiceRequest serviceRequest = null;
        try {
            ActiveMQObjectMessage msg = (ActiveMQObjectMessage) message;
            serviceRequest = (ServiceRequest) msg.getObject();
            ServiceRequestType serviceRequestType = serviceRequest.getRequestType();
            //Process the json
            serviceRequestType.process(serviceRequest);
        } catch (Exception e) {
            LOG.error("Error processing json: " + (serviceRequest==null?"":serviceRequest.getJson()), e);

            //TODO respond back to client using the request id or set the status of the request id to failure

            //TODO Handle poison messages
        }
    }
}
 
开发者ID:fizalihsan,项目名称:Fig,代码行数:22,代码来源:ServiceRequestConsumer.java

示例6: toMessage

import org.apache.activemq.command.ActiveMQObjectMessage; //导入依赖的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

示例7: transformToMap

import org.apache.activemq.command.ActiveMQObjectMessage; //导入依赖的package包/类
/**
 * Transform an ActiveMQMessage to a Map
 * 
 * @param msg - object message to transform
 * @return map object
 * @throws JMSException
 */
protected Map transformToMap(ActiveMQObjectMessage msg) throws JMSException {
    Properties props = new Properties();

    props.putAll(transformToMap((ActiveMQMessage)msg));
    if (msg.getObject() != null) {
        // Just add the class name and toString value of the object
        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSObjectClass", msg.getObject().getClass().getName());
        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSObjectString", getDisplayString(msg.getObject()));
    }
    return props;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:19,代码来源:MapTransformFilter.java

示例8: onMessage

import org.apache.activemq.command.ActiveMQObjectMessage; //导入依赖的package包/类
public void onMessage(Message message) {
	try {
		// receive log event in your consumer
		LoggingEvent event = (LoggingEvent)((ActiveMQObjectMessage)message).getObject();
		System.out.println("Received log [" + event.getLevel() + "]: "+ event.getMessage());
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:chipster,项目名称:chipster,代码行数:10,代码来源:Log4jJMSAppenderExample.java

示例9: setObjectPayload

import org.apache.activemq.command.ActiveMQObjectMessage; //导入依赖的package包/类
@Override
public void setObjectPayload(ObjectMessage msg, byte[] rawPayload) throws JMSException {
    ((ActiveMQObjectMessage) msg).setContent(new ByteSequence(rawPayload));
}
 
开发者ID:erik-wramner,项目名称:JmsTools,代码行数:5,代码来源:AmqObjectMessageAdapter.java

示例10: getObjectPayload

import org.apache.activemq.command.ActiveMQObjectMessage; //导入依赖的package包/类
@Override
public byte[] getObjectPayload(ObjectMessage msg) throws JMSException {
    return ((ActiveMQObjectMessage) msg).getContent().getData();
}
 
开发者ID:erik-wramner,项目名称:JmsTools,代码行数:5,代码来源:AmqObjectMessageAdapter.java

示例11: createObjectMessage

import org.apache.activemq.command.ActiveMQObjectMessage; //导入依赖的package包/类
protected ActiveMQObjectMessage createObjectMessage(HierarchicalStreamReader in) throws JMSException {
    ActiveMQObjectMessage objMsg = new ActiveMQObjectMessage();
    Object obj = getXStream().unmarshal(in);
    objMsg.setObject((Serializable) obj);
    return objMsg;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:7,代码来源:JmsFrameTranslator.java

示例12: createObjectMessage

import org.apache.activemq.command.ActiveMQObjectMessage; //导入依赖的package包/类
@Override
public ObjectMessage createObjectMessage() {
    return new ActiveMQObjectMessage();
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:5,代码来源:ActiveMQJMSVendor.java

示例13: createObject

import org.apache.activemq.command.ActiveMQObjectMessage; //导入依赖的package包/类
/**
 * @return a new object instance
 */
public DataStructure createObject() {
    return new ActiveMQObjectMessage();
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:7,代码来源:ActiveMQObjectMessageMarshaller.java

示例14: createObject

import org.apache.activemq.command.ActiveMQObjectMessage; //导入依赖的package包/类
@Override
public Object createObject() throws Exception {
   ActiveMQObjectMessage info = new ActiveMQObjectMessage();
   populateObject(info);
   return info;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:7,代码来源:ActiveMQObjectMessageTest.java

示例15: populateObject

import org.apache.activemq.command.ActiveMQObjectMessage; //导入依赖的package包/类
@Override
protected void populateObject(Object object) throws Exception {
   super.populateObject(object);
   ActiveMQObjectMessage info = (ActiveMQObjectMessage) object;

}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:7,代码来源:ActiveMQObjectMessageTest.java


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