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


Java AmqpException类代码示例

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


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

示例1: sendMessage

import org.springframework.amqp.AmqpException; //导入依赖的package包/类
public void sendMessage(final String serviceName, final String serviceMethodName,final String correlationId, Object request) {
	logger.info("sendMessage [this.{}, serviceMethodName:{} serviceName:{} correlationId: {}]", this.getClass(), serviceMethodName, serviceName, correlationId);
	rabbitTemplate.setConfirmCallback(this);
	rabbitTemplate.setCorrelationKey(correlationId);
	rabbitTemplate.convertAndSend(routingkey, request, new MessagePostProcessor() {            
    	@Override
        public Message postProcessMessage(Message message) throws AmqpException {
            message.getMessageProperties().setAppId(appId);
            message.getMessageProperties().setTimestamp(new Date());
            message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
            message.getMessageProperties().setCorrelationId(correlationId.getBytes());
            message.getMessageProperties().setHeader("ServiceMethodName", serviceMethodName);
            message.getMessageProperties().setHeader("ServiceName", serviceName);
            return message;
        }
    }, new CorrelationData(correlationId));
}
 
开发者ID:lemon-china,项目名称:lemon-rabbitmq,代码行数:18,代码来源:BasicService.java

示例2: getHealth

import org.springframework.amqp.AmqpException; //导入依赖的package包/类
@ResponseStatus(HttpStatus.OK)
@RequestMapping(method = RequestMethod.GET, path = "/health")
public
@ResponseBody
Map<String, List<HealthCheck>> getHealth() {
    Map<String, List<HealthCheck>> map = new HashMap<String, List<HealthCheck>>();
    List<HealthCheck> healthChecks = new ArrayList<HealthCheck>();
    Date dateNow = Calendar.getInstance().getTime();

    HealthCheck rabbitmq = new HealthCheck("shipping-rabbitmq", "OK", dateNow);
    HealthCheck app = new HealthCheck("shipping", "OK", dateNow);

    try {
        this.rabbitTemplate.execute(new ChannelCallback<String>() {
            @Override
            public String doInRabbit(Channel channel) throws Exception {
                Map<String, Object> serverProperties = channel.getConnection().getServerProperties();
                return serverProperties.get("version").toString();
            }
        });
    } catch ( AmqpException e ) {
        rabbitmq.setStatus("err");
    }

    healthChecks.add(rabbitmq);
    healthChecks.add(app);

    map.put("health", healthChecks);
    return map;
}
 
开发者ID:microservices-demo,项目名称:shipping,代码行数:31,代码来源:ShippingController.java

示例3: postProcessMessage

import org.springframework.amqp.AmqpException; //导入依赖的package包/类
@Override
public Message postProcessMessage(Message message) throws AmqpException{


    message.getMessageProperties().setHeader("my-header","Hello John Nash");
    message.getMessageProperties().setDelay(50000);//延迟5秒发送
    return  message;
}
 
开发者ID:capesonlee,项目名称:tangtang-spring-cloud,代码行数:9,代码来源:MyMessagePostProcessor.java

示例4: send

import org.springframework.amqp.AmqpException; //导入依赖的package包/类
public void send(final String exchange, final String routingKey,
                 final Message message, final CorrelationData correlationData)
        throws AmqpException {
    clientRequestInterceptor.handle(new RabbitClientRequestAdapter(message));
    super.send(exchange, routingKey, message, correlationData);
    clientResponseInterceptor.handle(new RabbitClientResponseAdapter(message));
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:8,代码来源:TracingRabbitTemplate.java

示例5: sendDataToQueue

import org.springframework.amqp.AmqpException; //导入依赖的package包/类
@Override
public void sendDataToQueue(String queueKey, Object message) {
	// convertAndSend:
	// 将Java对象转换为消息发送到匹配Key的交换机中Exchange,由于配置了JSON转换,这里是将Java对象转换成JSON字符串的形式
	try {
		logger.info("to send message:{}", message);
		amqpTemplate.convertAndSend(queueKey, message);
	} catch (AmqpException e) {
		logger.error(e.getMessage());
	}
}
 
开发者ID:funtl,项目名称:framework,代码行数:12,代码来源:MessageProducerImpl.java

示例6: postProcessMessage

import org.springframework.amqp.AmqpException; //导入依赖的package包/类
@Override
public Message postProcessMessage(Message message) throws AmqpException {
  Message localMessage = message;
  for (MessagePostProcessor postProcessor : postProcessorList) {
    localMessage = postProcessor.postProcessMessage(localMessage);
  }
  return localMessage;
}
 
开发者ID:netshoes,项目名称:spring-cloud-sleuth-amqp,代码行数:9,代码来源:CompositeMessagePostProcessor.java

示例7: convertAndSend

import org.springframework.amqp.AmqpException; //导入依赖的package包/类
@Override
public void convertAndSend(Object message, MessagePostProcessor messagePostProcessor)
    throws AmqpException {
  messagePostProcessor.postProcessMessage(convertMessageIfNecessary(message));
  mockManager.throwExceptionIfConfigured();
  logger.debug("convertAndSend: {} {}", message, messagePostProcessor);
}
 
开发者ID:netshoes,项目名称:spring-cloud-sleuth-amqp,代码行数:8,代码来源:RabbitTemplateMock.java

示例8: receiveAndReply

import org.springframework.amqp.AmqpException; //导入依赖的package包/类
@Override
public <R, S> boolean receiveAndReply(ReceiveAndReplyCallback<R, S> callback)
    throws AmqpException {
  mockManager.throwExceptionIfConfigured();
  logger.debug("receiveAndReply: {}", callback);
  return false;
}
 
开发者ID:netshoes,项目名称:spring-cloud-sleuth-amqp,代码行数:8,代码来源:RabbitTemplateMock.java

示例9: sendAndReceive

import org.springframework.amqp.AmqpException; //导入依赖的package包/类
@Override
public Message sendAndReceive(String exchange, String routingKey, Message message)
    throws AmqpException {
  mockManager.throwExceptionIfConfigured();
  logger.debug("sendAndReceive: {} {} {}", exchange, routingKey, message);
  return message;
}
 
开发者ID:netshoes,项目名称:spring-cloud-sleuth-amqp,代码行数:8,代码来源:RabbitTemplateMock.java

示例10: convertSendAndReceive

import org.springframework.amqp.AmqpException; //导入依赖的package包/类
@Override
public Object convertSendAndReceive(String exchange, String routingKey, Object message)
    throws AmqpException {
  mockManager.throwExceptionIfConfigured();
  logger.debug("convertSendAndReceive: {} {} {}", exchange, routingKey, message);
  return message;
}
 
开发者ID:netshoes,项目名称:spring-cloud-sleuth-amqp,代码行数:8,代码来源:RabbitTemplateMock.java

示例11: doNotCrashWhenNoQueue

import org.springframework.amqp.AmqpException; //导入依赖的package包/类
@Test
public void doNotCrashWhenNoQueue() throws Exception {
    doThrow(new AmqpException("test error")).when(rabbitTemplate).convertAndSend(anyString(), any(Shipment.class));
    Shipment original = new Shipment("someName");
    Shipment saved = shippingController.postShipping(original);
    verify(rabbitTemplate, times(1)).convertAndSend(anyString(), any(Shipment.class));
    assertThat(original, is(equalTo(saved)));
}
 
开发者ID:microservices-demo,项目名称:shipping,代码行数:9,代码来源:ITShippingController.java

示例12: sendEvent

import org.springframework.amqp.AmqpException; //导入依赖的package包/类
public void sendEvent(String apiKey, String channel, byte[] payload) {

        try {
            MessageProperties properties = new MessageProperties();
            properties.setHeader(RabbitMQDataConfig.MSG_HEADER_APIKEY, apiKey);
            properties.setHeader(RabbitMQDataConfig.MSG_HEADER_CHANNEL, channel);

            Message message = new Message(payload, properties);

            rabbitTemplate.convertAndSend("data.sub", message);
        } catch (AmqpException ex) {
            LOGGER.error("AmqpException while sending message to RabbitMQ...", ex);
        }
    }
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:15,代码来源:RabbitGateway.java

示例13: sendConfig

import org.springframework.amqp.AmqpException; //导入依赖的package包/类
public void sendConfig(String apiKey, String config) {

        try {
            MessageProperties properties = new MessageProperties();
            properties.setHeader(RabbitMQDataConfig.MSG_HEADER_APIKEY, apiKey);

            Message message = new Message(config.getBytes("UTF-8"), properties);

            rabbitTemplate.convertAndSend("mgmt.config.sub", message);
        } catch (AmqpException | UnsupportedEncodingException ex) {
            LOGGER.error("AmqpException while sending message to RabbitMQ...", ex);
        }

    }
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:15,代码来源:RabbitGateway.java

示例14: test

import org.springframework.amqp.AmqpException; //导入依赖的package包/类
@Test
public void test() throws Exception {
	Advice[] adviceChain = TestUtils.getPropertyValue(this.container, "adviceChain", Advice[].class);
	assertEquals(1, adviceChain.length);
	RetryTemplate retryTemplate = TestUtils.getPropertyValue(adviceChain[0], "retryOperations",
			RetryTemplate.class);
	assertEquals(5, TestUtils.getPropertyValue(retryTemplate, "retryPolicy.maxAttempts"));
	assertEquals(123L, TestUtils.getPropertyValue(retryTemplate, "backOffPolicy.initialInterval"));
	assertEquals(345L, TestUtils.getPropertyValue(retryTemplate, "backOffPolicy.maxInterval"));
	assertEquals(1.5, TestUtils.getPropertyValue(retryTemplate, "backOffPolicy.multiplier"));
	assertEquals("scsapp-testq", this.container.getQueueNames()[0]);
	assertFalse(TestUtils.getPropertyValue(this.container, "defaultRequeueRejected", Boolean.class));
	assertEquals(2, TestUtils.getPropertyValue(this.container, "concurrentConsumers"));
	assertEquals(3, TestUtils.getPropertyValue(this.container, "maxConcurrentConsumers"));
	assertEquals(AcknowledgeMode.NONE, TestUtils.getPropertyValue(this.container, "acknowledgeMode"));
	assertEquals(10, TestUtils.getPropertyValue(this.container, "prefetchCount"));
	assertEquals(5, TestUtils.getPropertyValue(this.container, "txSize"));

	this.rabbitTemplate.convertAndSend("", "scsapp-testq", "foo", new MessagePostProcessor() {

		@Override
		public org.springframework.amqp.core.Message postProcessMessage(
				org.springframework.amqp.core.Message message) throws AmqpException {
			message.getMessageProperties().getHeaders().put("bar", "baz");
			return message;
		}

	});
	Message<?> out = this.messageCollector.forChannel(this.channels.output()).poll(10, TimeUnit.SECONDS);
	assertNotNull(out);
	assertEquals("foo", out.getPayload());
	assertEquals("baz", out.getHeaders().get("bar"));
	assertNull(out.getHeaders().get(AmqpHeaders.DELIVERY_MODE));
}
 
开发者ID:spring-cloud-stream-app-starters,项目名称:rabbit,代码行数:35,代码来源:RabbitSourceTests.java

示例15: sendMessage

import org.springframework.amqp.AmqpException; //导入依赖的package包/类
/**
 * @param message
 * @param queue
 * @param correlationId
 * @throws JMSException
 * @throws AmqpException
 */
public void sendMessage(String message, Queue queue, String correlationId)
        throws AmqpException, JMSException {
    if (jmsTemplate != null) {
        jmsTemplate.send(queue, new MDWMessageCreator(message, correlationId, null, 0));
    }
    else if (rabbitTemplate != null) {
        rabbitTemplate.send(getExchange(queue.getQueueName()), null,
                new Message(message.getBytes(), null), new CorrelationData(correlationId));
    }

}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:19,代码来源:MDWMessageProducer.java


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