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


Java Message.getPayload方法代码示例

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


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

示例1: process

import org.springframework.integration.Message; //导入方法依赖的package包/类
public PersonTax process(Person item) {
    	
        Message<?> inputMessage = MessageBuilder.withPayload(item).build();
//
        Message<?> outputMessage = this.messagingGateway.sendAndReceive(this.integrationInputChannel, inputMessage);

//        return outputMessage;
        
        PersonTax personTax = (PersonTax) outputMessage.getPayload();
        
        if (item.getDependents() > 0) {
			personTax.setFree(true);
		}else{
			personTax.setFree(false);
		}
        
        personTax.setDate(new Date(System.currentTimeMillis()));
		personTax.setTax(item.getSalary()*1.05);
        
    	return personTax;
    }
 
开发者ID:osnircunha,项目名称:SpringFrameworkSamples,代码行数:22,代码来源:MyItemProcessor.java

示例2: executeOutboundOperation

import org.springframework.integration.Message; //导入方法依赖的package包/类
/**
 * Executes the outbound Sqs Operation.
 * 
 */
public Object executeOutboundOperation(final Message<?> message) {

	try {
		String serializedMessage = messageMarshaller.serialize(message);
		if (queue == null) {
			SendMessageRequest request = new SendMessageRequest(queueUrl,
					serializedMessage);
			SendMessageResult result = sqsClient.sendMessage(request);
			log.debug("Message sent, Id:" + result.getMessageId());
		} else {
			queue.add(serializedMessage);
		}
	} catch (MessageMarshallerException e) {
		log.error(e.getMessage(), e);
		throw new MessagingException(e.getMessage(), e.getCause());
	}

	return message.getPayload();
}
 
开发者ID:3pillarlabs,项目名称:spring-integration-aws,代码行数:24,代码来源:SqsExecutor.java

示例3: executeOutboundOperation

import org.springframework.integration.Message; //导入方法依赖的package包/类
/**
 * Executes the outbound Sns Operation.
 * 
 */
public Object executeOutboundOperation(final Message<?> message) {

	try {
		String serializedMessage = messageMarshaller.serialize(message);

		if (snsTestProxy == null) {
			PublishRequest request = new PublishRequest();
			PublishResult result = client.publish(request.withTopicArn(
					topicArn).withMessage(serializedMessage));
			log.debug("Published message to topic: "
					+ result.getMessageId());
		} else {
			snsTestProxy.dispatchMessage(serializedMessage);
		}

	} catch (MessageMarshallerException e) {
		log.error(e.getMessage(), e);
		throw new MessagingException(e.getMessage(), e.getCause());
	}

	return message.getPayload();
}
 
开发者ID:3pillarlabs,项目名称:spring-integration-aws,代码行数:27,代码来源:SnsExecutor.java

示例4: testArrayOfPojo

import org.springframework.integration.Message; //导入方法依赖的package包/类
@Test
public void testArrayOfPojo() throws MessageMarshallerException {

	TestPojo[] aryIn = new TestPojo[2];
	aryIn[0] = new TestPojo();
	aryIn[0].setName("John Doe");
	aryIn[0].setEmail("[email protected]");
	aryIn[1] = new TestPojo();
	aryIn[1].setName("Lionel Messi");
	aryIn[1].setEmail("[email protected]");

	String packet = marshaller.serialize(MessageBuilder.withPayload(aryIn)
			.build());
	Message<?> otherPacket = marshaller.deserialize(packet);

	TestPojo[] aryOut = (TestPojo[]) otherPacket.getPayload();

	assertTrue(Arrays.deepEquals(aryIn, aryOut));

}
 
开发者ID:3pillarlabs,项目名称:spring-integration-aws,代码行数:21,代码来源:JsonMessageMarshallerTest.java

示例5: correctMD5Test

import org.springframework.integration.Message; //导入方法依赖的package包/类
@Test
public void correctMD5Test() throws Exception {

	String payload = "Hello, World";
	String messageBody = messageMarshaller.serialize(MessageBuilder
			.withPayload(payload).build());
	com.amazonaws.services.sqs.model.Message sqsMessage = new com.amazonaws.services.sqs.model.Message();
	sqsMessage.setBody(messageBody);
	sqsMessage.setMD5OfBody(new String(Hex.encodeHex(Md5Utils
			.computeMD5Hash(messageBody.getBytes("UTF-8")))));

	ReceiveMessageResult result = new ReceiveMessageResult();
	result.setMessages(Collections.singletonList(sqsMessage));
	when(mockSQS.receiveMessage(any(ReceiveMessageRequest.class)))
			.thenReturn(result);

	Message<?> recvMessage = executor.poll();
	assertNotNull("message is not null", recvMessage);

	Message<?> enclosed = messageMarshaller
			.deserialize((String) recvMessage.getPayload());
	String recvPayload = (String) enclosed.getPayload();
	assertEquals("payload must match", payload, recvPayload);
}
 
开发者ID:3pillarlabs,项目名称:spring-integration-aws,代码行数:25,代码来源:SqsExecutorTest.java

示例6: prepareMessage

import org.springframework.integration.Message; //导入方法依赖的package包/类
/**
 * Prepare a message for outgoing email
 *
 * @param message
 * @return
 */
public Message<Map> prepareMessage(Message<?> message) {
	Map<String, Object> model = new HashMap<String, Object>();
	Map<String, Object> headers = new HashMap<String, Object>();
	headers.putAll(message.getHeaders());
	Object payload = message.getPayload();
	if (payload instanceof Comment) {
		model.put("comment", payload);
		// Decide which template
		Base about = ((Comment) payload).getAboutData();
		String templateName = null;
		if(((Comment) payload).getInResponseTo() != null) {
			templateName = "reply";
		} else if (about instanceof BaseData) {
			templateName = "comment";
		} else if (about instanceof Resource) {
			templateName = "resource";
		}
		if (templateName != null) {
			headers.put(HEADER_TEMPLATE_NAME, templates.get(templateName));
		} else {
			headers.put(HEADER_TEMPLATE_NAME,
					templates.get(defaultTemplateName));
		}
	}
	return new GenericMessage<Map>(model, headers);

}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:34,代码来源:EmailServiceHelper.java

示例7: splitMessage

import org.springframework.integration.Message; //导入方法依赖的package包/类
@Override
protected List<Message<Object>> splitMessage(Message<?> message) {
	List<Message<Object>> split = new ArrayList<Message<Object>>();
	Message<Object> m;
	for(Object o : (Iterable) message.getHeaders().get(requestKey)) {
		Map<String, Object> newHeaders = new HashMap<String, Object>();
		newHeaders.putAll(message.getHeaders());
		if(responseKey != null) {
			newHeaders.put(responseKey, o);
		}
		m = new GenericMessage<Object>(message.getPayload(), newHeaders);
		split.add(m);
	}
	return split;
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:16,代码来源:HeaderCollectionSplitter.java

示例8: process

import org.springframework.integration.Message; //导入方法依赖的package包/类
/**
 * Processes the thread id
 *
 * @param id the id
 * @return the async context
 */
public AsyncContext process(String id) {
	IdMessageSelector selector = (IdMessageSelector) ContextLoader
			.getCurrentWebApplicationContext().getBean(
					IdMessageSelector.BEAN);
	selector.setThreadId(id);
	List<Message<?>> listMessages = channel.purge(selector);
	if (listMessages.size() > 0) {
		Message<?> reportMessage = listMessages.get(0); // 1 a 1;
		if (reportMessage != null) {
			return (AsyncContext) reportMessage.getPayload();
		}
	}
	return null;
}
 
开发者ID:mattiamascia,项目名称:atask,代码行数:21,代码来源:DownloadCtr.java

示例9: accept

import org.springframework.integration.Message; //导入方法依赖的package包/类
@Override
public boolean accept(Message<?> message) {
	if (message != null) {
		AsyncContext asyncContext = (AsyncContext) message.getPayload();
		String id = (String) message.getHeaders().get(
				AsyncContext.THREAD_ID);
		if (asyncContext != null
				&& AsyncContext.getId(message.getPayload())
						.equalsIgnoreCase(id)) {
			return false;
		}
	}
	return true;
}
 
开发者ID:mattiamascia,项目名称:atask,代码行数:15,代码来源:AsyncMessageSelector.java

示例10: accept

import org.springframework.integration.Message; //导入方法依赖的package包/类
@Override
public boolean accept(Message<?> message) {
	if (message != null) {
		AsyncContext asyncContext = (AsyncContext) message.getPayload();
		String id = (String) message.getHeaders().get(
				AsyncContext.THREAD_ID);
		if (asyncContext != null
				&& threadId
						.equalsIgnoreCase(id)) {
			return false;
		}
	}
	return true;
}
 
开发者ID:mattiamascia,项目名称:atask,代码行数:15,代码来源:IdMessageSelector.java

示例11: afterExecute

import org.springframework.integration.Message; //导入方法依赖的package包/类
/**
 * When a thread is finished and it exists a Message in the channel for the current thread.
 * It gets the PushContext and it prepares the message to push to client.
 * 
 * @param r the runnable that has completed
    	*  @param t the exception that caused termination, or null if
       *  execution completed normally
*/
@Override
protected void afterExecute(Runnable r, Throwable t) {
	super.afterExecute(r, t);

	try {
		if (r instanceof FutureTask<?>) {
			if (channel == null) {
				channel = (AsyncChannel) ContextLoader
						.getCurrentWebApplicationContext().getBean(
								AsyncChannel.BEAN);
				asyncMessageSelector = (AsyncMessageSelector) ContextLoader
						.getCurrentWebApplicationContext().getBean(
								AsyncMessageSelector.BEAN);
			}
			List<Message<?>> listMessages = channel
					.scan(asyncMessageSelector);
			if (listMessages.size() > 0) {
				Message<?> message = (Message<?>) listMessages.get(0);
				AsyncContext asyncContext = (AsyncContext) message
						.getPayload();
				
				//push to the client
				PushModel p = asyncContext.getPushModel();
				if (p != null) {
					p.setThreadId(AsyncContext.getId(message.getPayload()));
					PushModel.push(p.getBroadcast(), p);
				}
			}

		}
	} catch (Throwable e) {
		t = e;
	}

}
 
开发者ID:mattiamascia,项目名称:atask,代码行数:44,代码来源:ThreadPoolExecutor.java

示例12: serialize

import org.springframework.integration.Message; //导入方法依赖的package包/类
@Override
public String serialize(Message<?> message)
		throws MessageMarshallerException {

	try {
		final Map<String, String> messageProperties = extractMessageProperties(message
				.getHeaders());
		final Map<String, String> headersMap = convertHeadersToMap(message
				.getHeaders());
		final Object payload = message.getPayload();

		return getObjectMapper().writeValueAsString(new Object() {

			@SuppressWarnings("unused")
			public Object getPayload() {
				return payload;
			}

			@SuppressWarnings("unused")
			public String getPayloadClazz() {
				return payload.getClass().getName();
			}

			@SuppressWarnings("unused")
			public Map<String, String> getHeaders() {
				return headersMap;
			}

			@SuppressWarnings("unused")
			public Map<String, String> getProperties() {
				return messageProperties;
			}
		});

	} catch (Exception e) {
		throw new MessageMarshallerException(e.getMessage(), e.getCause());
	}
}
 
开发者ID:3pillarlabs,项目名称:spring-integration-aws,代码行数:39,代码来源:JsonMessageMarshaller.java

示例13: testPrimitivesPayload

import org.springframework.integration.Message; //导入方法依赖的package包/类
@Test
public void testPrimitivesPayload() throws MessageMarshallerException {

	Integer i = new Integer(1);
	String packet = marshaller.serialize(MessageBuilder.withPayload(i)
			.build());

	Message<?> recvd = marshaller.deserialize(packet);
	Integer j = (Integer) recvd.getPayload();

	assertEquals(i, j);
}
 
开发者ID:3pillarlabs,项目名称:spring-integration-aws,代码行数:13,代码来源:JsonMessageMarshallerTest.java

示例14: testArrayofPrimitivesPayload

import org.springframework.integration.Message; //导入方法依赖的package包/类
@Test
public void testArrayofPrimitivesPayload()
		throws MessageMarshallerException {

	Integer[] aryIn = new Integer[] { 1, 2 };

	String packet = marshaller.serialize(MessageBuilder.withPayload(aryIn)
			.build());
	Message<?> otherPacket = marshaller.deserialize(packet);
	Integer[] aryOut = (Integer[]) otherPacket.getPayload();

	assertTrue(Arrays.deepEquals(aryIn, aryOut));
}
 
开发者ID:3pillarlabs,项目名称:spring-integration-aws,代码行数:14,代码来源:JsonMessageMarshallerTest.java

示例15: testSubscription

import org.springframework.integration.Message; //导入方法依赖的package包/类
@Test
public void testSubscription() throws Exception {
	context = new ClassPathXmlApplicationContext(
			"SnsSubscriptionsParserTests.xml", getClass());

	final String expectedPayload = "Hello, World";

	MessageChannel target = (MessageChannel) context.getBean("target");
	target.send(MessageBuilder.withPayload(expectedPayload).build());

	PollableChannel sink = (PollableChannel) context.getBean("sink");
	Message<?> message = sink.receive(1000);
	String payload = (String) message.getPayload();
	assertEquals(expectedPayload, payload);
}
 
开发者ID:3pillarlabs,项目名称:spring-integration-aws,代码行数:16,代码来源:SnsSubscriptionsParserTests.java


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