• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AmqpRejectAndDontRequeueException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: handleFileStagedEvent

import org.springframework.amqp.AmqpRejectAndDontRequeueException; //导入依赖的package包/类
@RabbitListener(queues = Constants.Queues.FILE_STAGED)
public void handleFileStagedEvent(FileMessage fileMessage) {
    if(!StringUtils.isEmpty(fileMessage.getContentType()) &&
        fileMessage.getMediaType().equals(FileMediaTypes.HCA_DATA_FILE)){
        try {
            fileService.updateStagedFileUrl(fileMessage.getStagingAreaId(),
                    fileMessage.getFileName(),
                    fileMessage.getCloudUrl());
        } catch (CoreEntityNotFoundException | RuntimeException e) {
            throw new AmqpRejectAndDontRequeueException(e.getMessage());
        }
    }
}
 
开发者ID:HumanCellAtlas,项目名称:ingest-core,代码行数:14,代码来源:FileListener.java


示例2: checkContentTypeJson

import org.springframework.amqp.AmqpRejectAndDontRequeueException; //导入依赖的package包/类
/**
 * Method to validate if content type is set in the message properties.
 *
 * @param message
 *            the message to get validated
 */
private void checkContentTypeJson(final Message message) {
    if (message.getBody().length == 0) {
        return;
    }
    final MessageProperties messageProperties = message.getMessageProperties();
    final String headerContentType = (String) messageProperties.getHeaders().get("content-type");
    if (null != headerContentType) {
        messageProperties.setContentType(headerContentType);
    }
    final String contentType = messageProperties.getContentType();
    if (contentType != null && contentType.contains("json")) {
        return;
    }
    throw new AmqpRejectAndDontRequeueException("Content-Type is not JSON compatible");
}
 
开发者ID:eclipse,项目名称:hawkbit-examples,代码行数:22,代码来源:DmfReceiverService.java


示例3: onAuthenticationRequest

import org.springframework.amqp.AmqpRejectAndDontRequeueException; //导入依赖的package包/类
/**
 * Executed on an authentication request.
 * 
 * @param message
 *            the amqp message
 * @return the rpc message back to supplier.
 */
@RabbitListener(queues = "${hawkbit.dmf.rabbitmq.authenticationReceiverQueue:authentication_receiver}", containerFactory = "listenerContainerFactory")
public Message onAuthenticationRequest(final Message message) {
    checkContentTypeJson(message);
    final SecurityContext oldContext = SecurityContextHolder.getContext();
    try {
        return handleAuthenticationMessage(message);
    } catch (final RuntimeException ex) {
        throw new AmqpRejectAndDontRequeueException(ex);
    } finally {
        SecurityContextHolder.setContext(oldContext);
    }
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:20,代码来源:AmqpAuthenticationMessageHandler.java


示例4: updateActionStatusWithoutActionId

import org.springframework.amqp.AmqpRejectAndDontRequeueException; //导入依赖的package包/类
@Test
@Description("Tests the update of an action of a target without a exist action id")
public void updateActionStatusWithoutActionId() {
    when(controllerManagementMock.findActionWithDetails(any())).thenReturn(Optional.empty());
    final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
    messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
    final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.DOWNLOAD);
    final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(actionUpdateStatus,
            messageProperties);

    try {
        amqpMessageHandlerService.onMessage(message, MessageType.EVENT.name(), TENANT, "vHost");
        fail("AmqpRejectAndDontRequeueException was excepeted since no action id was set");
    } catch (final AmqpRejectAndDontRequeueException exception) {
        // test ok - exception was excepted
    }
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:18,代码来源:AmqpMessageHandlerServiceTest.java


示例5: updateActionStatusWithoutExistActionId

import org.springframework.amqp.AmqpRejectAndDontRequeueException; //导入依赖的package包/类
@Test
@Description("Tests the update of an action of a target without a exist action id")
public void updateActionStatusWithoutExistActionId() {
    final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
    messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
    when(controllerManagementMock.findActionWithDetails(any())).thenReturn(Optional.empty());

    final DmfActionUpdateStatus actionUpdateStatus = createActionUpdateStatus(DmfActionStatus.DOWNLOAD);
    final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(actionUpdateStatus,
            messageProperties);

    try {
        amqpMessageHandlerService.onMessage(message, MessageType.EVENT.name(), TENANT, "vHost");
        fail("AmqpRejectAndDontRequeueException was excepeted since no action id was set");
    } catch (final AmqpRejectAndDontRequeueException exception) {
        // test ok - exception was excepted
    }

}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:20,代码来源:AmqpMessageHandlerServiceTest.java


示例6: consume

import org.springframework.amqp.AmqpRejectAndDontRequeueException; //导入依赖的package包/类
@StreamListener(UserLogBinding.CHANNEL_NAME)
void consume(@Validated UserLogMessage message) {
    try {
        if (logRepository.getByLogId(message.getLogId()) == null) {
            Log log = new Log();
            BeanUtils.copyProperties(message, log);
            logRepository.create(log);
        }
    } catch (Exception e) {
        throw new AmqpRejectAndDontRequeueException(e);
    }
}
 
开发者ID:richterplus,项目名称:spring-cloud-sample,代码行数:13,代码来源:UserLogConsumer.java


示例7: checkContentTypeJson

import org.springframework.amqp.AmqpRejectAndDontRequeueException; //导入依赖的package包/类
protected static void checkContentTypeJson(final Message message) {
    final MessageProperties messageProperties = message.getMessageProperties();
    if (messageProperties.getContentType() != null && messageProperties.getContentType().contains("json")) {
        return;
    }
    throw new AmqpRejectAndDontRequeueException("Content-Type is not JSON compatible");
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:8,代码来源:BaseAmqpService.java


示例8: onMessage

import org.springframework.amqp.AmqpRejectAndDontRequeueException; //导入依赖的package包/类
/**
 * * Executed if a amqp message arrives.
 * 
 * @param message
 *            the message
 * @param type
 *            the type
 * @param tenant
 *            the tenant
 * @param virtualHost
 *            the virtual host
 * @return the rpc message back to supplier.
 */
public Message onMessage(final Message message, final String type, final String tenant, final String virtualHost) {

    final SecurityContext oldContext = SecurityContextHolder.getContext();
    try {
        final MessageType messageType = MessageType.valueOf(type);
        switch (messageType) {
        case THING_CREATED:
            checkContentTypeJson(message);
            setTenantSecurityContext(tenant);
            registerTarget(message, virtualHost);
            break;
        case EVENT:
            checkContentTypeJson(message);
            setTenantSecurityContext(tenant);
            handleIncomingEvent(message);
            break;
        case PING:
            if (isCorrelationIdNotEmpty(message)) {
                amqpMessageDispatcherService.sendPingReponseToDmfReceiver(message, tenant, virtualHost);
            }
            break;
        default:
            logAndThrowMessageError(message, "No handle method was found for the given message type.");
        }
    } catch (final IllegalArgumentException ex) {
        throw new AmqpRejectAndDontRequeueException("Invalid message!", ex);
    } finally {
        SecurityContextHolder.setContext(oldContext);
    }
    return null;
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:45,代码来源:AmqpMessageHandlerService.java


示例9: wrongContentType

import org.springframework.amqp.AmqpRejectAndDontRequeueException; //导入依赖的package包/类
@Test
@Description("Tests not allowed content-type in message")
public void wrongContentType() {
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setContentType("xml");
    final Message message = new Message(new byte[0], messageProperties);
    try {
        amqpMessageHandlerService.onMessage(message, MessageType.THING_CREATED.name(), TENANT, "vHost");
        fail("AmqpRejectAndDontRequeueException was excepeted due to worng content type");
    } catch (final AmqpRejectAndDontRequeueException e) {
    }
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:13,代码来源:AmqpMessageHandlerServiceTest.java


示例10: createThingWitoutReplyTo

import org.springframework.amqp.AmqpRejectAndDontRequeueException; //导入依赖的package包/类
@Test
@Description("Tests the creation of a thing without a 'reply to' header in message.")
public void createThingWitoutReplyTo() {
    final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED, null);
    messageProperties.setHeader(MessageHeaderKey.THING_ID, "1");
    final Message message = messageConverter.toMessage("", messageProperties);

    try {
        amqpMessageHandlerService.onMessage(message, MessageType.THING_CREATED.name(), TENANT, "vHost");
        fail("AmqpRejectAndDontRequeueException was excepeted since no replyTo header was set");
    } catch (final AmqpRejectAndDontRequeueException exception) {
        // test ok - exception was excepted
    }

}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:16,代码来源:AmqpMessageHandlerServiceTest.java


示例11: createThingWithoutID

import org.springframework.amqp.AmqpRejectAndDontRequeueException; //导入依赖的package包/类
@Test
@Description("Tests the creation of a target/thing without a thingID by calling the same method that incoming RabbitMQ messages would access.")
public void createThingWithoutID() {
    final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED);
    final Message message = messageConverter.toMessage(new byte[0], messageProperties);
    try {
        amqpMessageHandlerService.onMessage(message, MessageType.THING_CREATED.name(), TENANT, "vHost");
        fail("AmqpRejectAndDontRequeueException was excepeted since no thingID was set");
    } catch (final AmqpRejectAndDontRequeueException exception) {
        // test ok - exception was excepted
    }
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:13,代码来源:AmqpMessageHandlerServiceTest.java


示例12: unknownMessageType

import org.springframework.amqp.AmqpRejectAndDontRequeueException; //导入依赖的package包/类
@Test
@Description("Tests the call of the same method that incoming RabbitMQ messages would access with an unknown message type.")
public void unknownMessageType() {
    final String type = "bumlux";
    final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED);
    messageProperties.setHeader(MessageHeaderKey.THING_ID, "");
    final Message message = messageConverter.toMessage(new byte[0], messageProperties);

    try {
        amqpMessageHandlerService.onMessage(message, type, TENANT, "vHost");
        fail("AmqpRejectAndDontRequeueException was excepeted due to unknown message type");
    } catch (final AmqpRejectAndDontRequeueException exception) {
        // test ok - exception was excepted
    }
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:16,代码来源:AmqpMessageHandlerServiceTest.java


示例13: logAndThrowMessageError

import org.springframework.amqp.AmqpRejectAndDontRequeueException; //导入依赖的package包/类
protected static final void logAndThrowMessageError(final Message message, final String error) {
    LOGGER.warn("Warning! \"{}\" reported by message: {}", error, message);
    throw new AmqpRejectAndDontRequeueException(error);
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:5,代码来源:BaseAmqpService.java


示例14: handleMessage

import org.springframework.amqp.AmqpRejectAndDontRequeueException; //导入依赖的package包/类
public void handleMessage(RetryTestBean message) {
    unretry.countDown();
    throw new AmqpRejectAndDontRequeueException("test");
}
 
开发者ID:ctc-g,项目名称:sinavi-jfw,代码行数:5,代码来源:MessageListenerRetryTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java QualifierValue类代码示例发布时间:2022-05-22
下一篇:
Java PropertyInputMeta类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap