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


Java Headers类代码示例

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


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

示例1: processMessage

import org.springframework.messaging.handler.annotation.Headers; //导入依赖的package包/类
/**
 * Processes a JMS message.
 *
 * @param payload the message payload.
 * @param allHeaders the JMS headers.
 */
@JmsListener(id = HerdJmsDestinationResolver.SQS_DESTINATION_HERD_INCOMING,
    containerFactory = "jmsListenerContainerFactory", destination = HerdJmsDestinationResolver.SQS_DESTINATION_HERD_INCOMING)
public void processMessage(String payload, @Headers Map<Object, Object> allHeaders)
{
    LOGGER.info("JMS message received from the queue. jmsQueueName=\"{}\" jmsMessageHeaders=\"{}\" jmsMessagePayload={}",
        HerdJmsDestinationResolver.SQS_DESTINATION_HERD_INCOMING, allHeaders, payload);

    // Process the message as S3 notification.
    boolean messageProcessed = processS3Notification(payload);

    // If message is not processed as S3 notification, then process it as ESB system monitor message.
    if (!messageProcessed)
    {
        messageProcessed = processEsbSystemMonitorMessage(payload);
    }

    if (!messageProcessed)
    {
        // The message was not processed, log the error.
        LOGGER.error("Failed to process message from the JMS queue. jmsQueueName=\"{}\" jmsMessagePayload={}",
            HerdJmsDestinationResolver.SQS_DESTINATION_HERD_INCOMING, payload);
    }
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:30,代码来源:HerdJmsMessageListener.java

示例2: mix

import org.springframework.messaging.handler.annotation.Headers; //导入依赖的package包/类
@WampCallListener(value = "messageMethod/{id}")
public String mix(String param1, CallMessage message, int param2,
		WampSession wampSession, @Headers Map<String, Object> headers,
		@Header(value = "WAMP_MESSAGE_TYPE") WampMessageType wampMessageType,
		float param3, @DestinationVariable("id") int id, String param4) {

	assertThat(param1).isEqualTo("param1");
	assertThat(message).isNotNull();
	assertThat(message.getDestination()).isEqualTo("messageMethod/23");
	assertThat(param2).isEqualTo(2);
	assertThat(wampSession).isNotNull();
	assertThat(headers).hasSize(5);
	assertThat(wampMessageType).isEqualTo(WampMessageType.CALL);
	assertThat(param3).isEqualTo(3.3f);
	assertThat(id).isEqualTo(23);
	assertThat(param4).isEqualTo("param4");

	return "mix";
}
 
开发者ID:ralscha,项目名称:wampspring,代码行数:20,代码来源:CallParameterTestService.java

示例3: headersMethod

import org.springframework.messaging.handler.annotation.Headers; //导入依赖的package包/类
@WampProcedure(value = "headersMethod")
public String headersMethod(@Headers Map<String, Object> headers) {
	assertThat(headers).containsOnlyKeys("WAMP_SESSION_ID", "WEBSOCKET_SESSION_ID",
			"WAMP_MESSAGE_CODE");

	return "headersMethod called";
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:8,代码来源:CallParameterTestService.java

示例4: mix

import org.springframework.messaging.handler.annotation.Headers; //导入依赖的package包/类
@WampProcedure(name = "mix")
public String mix(String param1, CallMessage message, int param2,
		@Headers Map<String, Object> headers,
		@Header(value = "WAMP_MESSAGE_CODE") long code, float param3, String param4) {

	assertThat(param1).isEqualTo("param1");
	assertThat(message).isNotNull();
	assertThat(param2).isEqualTo(2);
	assertThat(headers).hasSize(3);
	assertThat(code).isEqualTo(CallMessage.CODE);
	assertThat(param3).isEqualTo(3.3f);
	assertThat(param4).isEqualTo("param4");

	return "mix";
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:16,代码来源:CallParameterTestService.java

示例5: supportsParameter

import org.springframework.messaging.handler.annotation.Headers; //导入依赖的package包/类
@Override
public boolean supportsParameter(MethodParameter parameter) {
	Class<?> paramType = parameter.getParameterType();
	return ((parameter.hasParameterAnnotation(Headers.class) && Map.class.isAssignableFrom(paramType)) ||
			MessageHeaders.class == paramType ||
			MessageHeaderAccessor.class.isAssignableFrom(paramType));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:HeadersMethodArgumentResolver.java

示例6: handleMessage

import org.springframework.messaging.handler.annotation.Headers; //导入依赖的package包/类
@SuppressWarnings("unused")
private void handleMessage(
		@Headers Map<String, ?> param1,
		@Headers String param2,
		MessageHeaders param3,
		MessageHeaderAccessor param4,
		TestMessageHeaderAccessor param5) {
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:HeadersMethodArgumentResolverTests.java

示例7: resolveHeaders

import org.springframework.messaging.handler.annotation.Headers; //导入依赖的package包/类
public void resolveHeaders(String content, @Headers Map<String, Object> headers) {
	invocations.put("resolveHeaders", true);
	assertEquals("Wrong payload resolution", "my payload", content);
	assertNotNull("headers not injected", headers);
	assertEquals("Missing JMS message id header", "abcd-1234", headers.get(JmsHeaders.MESSAGE_ID));
	assertEquals("Missing custom header", 1234, headers.get("customInt"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:MethodJmsListenerEndpointTests.java

示例8: processMessage

import org.springframework.messaging.handler.annotation.Headers; //导入依赖的package包/类
/**
 * Processes a JMS message.
 *
 * @param payload the message payload
 * @param allHeaders the JMS headers
 */
@JmsListener(id = HerdJmsDestinationResolver.SQS_DESTINATION_SEARCH_INDEX_UPDATE_QUEUE,
    containerFactory = "jmsListenerContainerFactory",
    destination = HerdJmsDestinationResolver.SQS_DESTINATION_SEARCH_INDEX_UPDATE_QUEUE)
public void processMessage(String payload, @Headers Map<Object, Object> allHeaders)
{
    // Call the process message with retry private method.
    processMessageWithRetry(payload, allHeaders);
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:15,代码来源:SearchIndexUpdateJmsMessageListener.java

示例9: processMessageWithRetry

import org.springframework.messaging.handler.annotation.Headers; //导入依赖的package包/类
/**
 * Processes a JMS message with retry.
 * This process message with retry method will attempt to process the message up to 4 times
 * with a 2 second, 4 second, 8 second, and 16 second exponential back off
 *
 * @param payload the message payload
 * @param allHeaders the JMS headers
 */
@Retryable(maxAttempts = 4, value = ListenerExecutionFailedException.class, backoff = @Backoff(delay = 2000, multiplier = 2))
private void processMessageWithRetry(String payload, @Headers Map<Object, Object> allHeaders)
{
    LOGGER.info("Message received from the JMS queue. jmsQueueName=\"{}\" jmsMessageHeaders=\"{}\" jmsMessagePayload={}",
        HerdJmsDestinationResolver.SQS_DESTINATION_SEARCH_INDEX_UPDATE_QUEUE, allHeaders, payload);
    try
    {
        // Unmarshall the SearchIndexUpdateDto from a JSON string to a SearchIndexUpdateDto object
        SearchIndexUpdateDto searchIndexUpdateDto = jsonHelper.unmarshallJsonToObject(SearchIndexUpdateDto.class, payload);

        // If the message type is null, this message is in the original message format.
        if (searchIndexUpdateDto.getMessageType() == null)
        {
            businessObjectDefinitionService.updateSearchIndexDocumentBusinessObjectDefinition(searchIndexUpdateDto);
        }
        else
        {
            switch (searchIndexUpdateDto.getMessageType())
            {
                case MESSAGE_TYPE_BUSINESS_OBJECT_DEFINITION_UPDATE:
                    businessObjectDefinitionService.updateSearchIndexDocumentBusinessObjectDefinition(searchIndexUpdateDto);
                    break;
                case MESSAGE_TYPE_TAG_UPDATE:
                    tagService.updateSearchIndexDocumentTag(searchIndexUpdateDto);
                    break;
                default:
                    LOGGER.error("Unknown message type.");
                    break;
            }
        }
    }
    catch (IOException ioException)
    {
        LOGGER.warn("Could not unmarshall JSON to SearchIndexUpdateDto object.", ioException);
    }
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:45,代码来源:SearchIndexUpdateJmsMessageListener.java

示例10: processMessage

import org.springframework.messaging.handler.annotation.Headers; //导入依赖的package包/类
/**
 * Processes a JMS message.
 *
 * @param payload the message payload
 * @param allHeaders the JMS headers
 */
@JmsListener(id = HerdJmsDestinationResolver.SQS_DESTINATION_STORAGE_POLICY_SELECTOR_JOB_SQS_QUEUE,
    containerFactory = "storagePolicyProcessorJmsListenerContainerFactory",
    destination = HerdJmsDestinationResolver.SQS_DESTINATION_STORAGE_POLICY_SELECTOR_JOB_SQS_QUEUE)
public void processMessage(String payload, @Headers Map<Object, Object> allHeaders)
{
    LOGGER.info("Message received from the JMS queue. jmsQueueName=\"{}\" jmsMessageHeaders=\"{}\" jmsMessagePayload={}",
        HerdJmsDestinationResolver.SQS_DESTINATION_STORAGE_POLICY_SELECTOR_JOB_SQS_QUEUE, allHeaders, payload);

    // Process the message as storage policy selection message.
    try
    {
        // Process messages coming from the storage policy selector job.
        StoragePolicySelection storagePolicySelection = jsonHelper.unmarshallJsonToObject(StoragePolicySelection.class, payload);

        LOGGER.debug("Received storage policy selection message: businessObjectDataKey={} storagePolicyKey={} storagePolicyVersion={}",
            jsonHelper.objectToJson(storagePolicySelection.getBusinessObjectDataKey()),
            jsonHelper.objectToJson(storagePolicySelection.getStoragePolicyKey()), storagePolicySelection.getStoragePolicyVersion());

        // Process the storage policy selection message.
        storagePolicyProcessorService.processStoragePolicySelectionMessage(storagePolicySelection);
    }
    catch (RuntimeException | IOException e)
    {
        // Log a warning message if storage unit status is already ARCHIVED. Such error case is typically caused by a duplicate SQS message.
        if (e instanceof IllegalArgumentException &&
            e.getMessage().startsWith(String.format("Storage unit status is \"%s\"", StorageUnitStatusEntity.ARCHIVED)))
        {
            LOGGER.warn("Failed to process message from the JMS queue. jmsQueueName=\"{}\" jmsMessagePayload={}",
                HerdJmsDestinationResolver.SQS_DESTINATION_STORAGE_POLICY_SELECTOR_JOB_SQS_QUEUE, payload, e);
        }
        // Otherwise, log an error.
        else
        {
            LOGGER.error("Failed to process message from the JMS queue. jmsQueueName=\"{}\" jmsMessagePayload={}",
                HerdJmsDestinationResolver.SQS_DESTINATION_STORAGE_POLICY_SELECTOR_JOB_SQS_QUEUE, payload, e);
        }
    }
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:45,代码来源:StoragePolicyProcessorJmsMessageListener.java

示例11: handleEvents

import org.springframework.messaging.handler.annotation.Headers; //导入依赖的package包/类
@ServiceActivator(inputChannel = EventSink.INPUT)
public void handleEvents(Event event, @Headers Map<String, Object> headers) throws InterruptedException {
	log.info("Received the following message with headers [{}] and body [{}]", headers, event);
	Span newSpan = tracer.createSpan("inside_reporting");
	reportingRepository.createOrUpdate(event);
	newSpan.logEvent("savedEvent");
	log.info("Saved event to the db", headers, event);
	tracer.close(newSpan);
}
 
开发者ID:spring-cloud-samples,项目名称:brewery,代码行数:10,代码来源:EventListener.java

示例12: receive

import org.springframework.messaging.handler.annotation.Headers; //导入依赖的package包/类
@StreamListener(Processor.INPUT)
public void receive(@Payload StreamListenerTestUtils.FooPojo fooPojo,
		@Headers Map<String, Object> headers,
		@Header(MessageHeaders.CONTENT_TYPE) String contentType) {
	this.receivedArguments.add(fooPojo);
	this.receivedArguments.add(headers);
	this.receivedArguments.add(contentType);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:9,代码来源:StreamListenerAnnotatedMethodArgumentsTests.java

示例13: headersMethod

import org.springframework.messaging.handler.annotation.Headers; //导入依赖的package包/类
@WampCallListener(value = "headersMethod")
public String headersMethod(@Headers Map<String, Object> headers) {

	assertThat(headers).hasSize(4).containsKey("WAMP_SESSION")
			.containsKey("PRINCIPAL").containsKey("WEBSOCKET_SESSION_ID")
			.containsKey("WAMP_MESSAGE_TYPE");

	assertThat(
			(WampMessageType) headers.get(WampMessageHeader.WAMP_MESSAGE_TYPE.name()))
					.isEqualTo(WampMessageType.CALL);

	return "headersMethod called";
}
 
开发者ID:ralscha,项目名称:wampspring,代码行数:14,代码来源:CallParameterTestService.java

示例14: receiveMessage

import org.springframework.messaging.handler.annotation.Headers; //导入依赖的package包/类
@RuntimeUse
@SqsListener("QueueListenerTest")
public void receiveMessage(String message, @Header(value = "SenderId", required = false) String senderId, @Headers Map<String, Object> allHeaders) {
    LOGGER.debug("Received message with content {}", message);
    this.receivedMessages.add(message);
    this.senderId = senderId;
    this.allHeaders = allHeaders;
    this.getCountDownLatch().countDown();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:10,代码来源:QueueListenerTest.java

示例15: notify

import org.springframework.messaging.handler.annotation.Headers; //导入依赖的package包/类
@MessageMapping("/ws-notify")
public void notify(@Payload PersonalData personalData, @Headers Map<String, String> headers) {
    System.out.println(personalData);
    simpMessagingTemplate.convertAndSendToUser("user", "/queue/ws-welcome", new WelcomeNewPerson("Hello " + personalData.getFirsName() + " " + personalData.getLastName()));
}
 
开发者ID:borysfan,项目名称:websocket-poc,代码行数:6,代码来源:PersonWebSocketController.java


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