org.springframework.messaging.MessageChannel.send()

Here are the examples of the java api org.springframework.messaging.MessageChannel.send() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

55 Examples 7

19 Source : ProviderService.java
with GNU Affero General Public License v3.0
from romeoblog

public <T> void sendWithTags(T msg, String tag) {
    Message message = MessageBuilder.createMessage(msg, new MessageHeaders(Stream.of(tag).collect(Collectors.toMap(str -> MessageConst.PROPERTY_TAGS, String::toString))));
    output.send(message);
}

19 Source : ProviderService.java
with GNU Affero General Public License v3.0
from romeoblog

public void send(String message) {
    output.send(MessageBuilder.withPayload(message).build());
}

19 Source : SimpleController.java
with Apache License 2.0
from q920447939

@GetMapping("/simple/send2")
public boolean send2(@RequestParam String message) {
    MessageChannel messageChannel = sayingServier.xiaoming();
    return messageChannel.send(new GenericMessage<>("hello .this is send2 method."));
}

19 Source : Sender.java
with MIT License
from PacktPublishing

public void send(Object message) {
    // template.convertAndSend("InventoryQ", message);
    messageChannel.send(MessageBuilder.withPayload(message).build());
}

19 Source : ProductService.java
with MIT License
from cassiomolin

public void deleteProduct(String id) {
    Product product = productRepository.findOne(id);
    if (product == null) {
        throw new NotFoundException();
    } else {
        productRepository.delete(id);
        productDeletedMessageChannel.send(MessageBuilder.withPayload(product).build());
    }
}

19 Source : ProductService.java
with MIT License
from cassiomolin

public void updateProduct(Product product) {
    product = productRepository.save(product);
    productUpdatedMessageChannel.send(MessageBuilder.withPayload(product).build());
}

19 Source : QueueMessageChannelTest.java
with Apache License 2.0
from awspring

@Test
void sendMessage_serviceThrowsError_throwsMessagingException() throws Exception {
    // Arrange
    AmazonSQSAsync amazonSqs = mock(AmazonSQSAsync.clreplaced);
    Message<String> stringMessage = MessageBuilder.withPayload("message content").build();
    MessageChannel messageChannel = new QueueMessageChannel(amazonSqs, "http://testQueue");
    when(amazonSqs.sendMessage(new SendMessageRequest("http://testQueue", "message content").withDelaySeconds(0).withMessageAttributes(isNotNull()))).thenThrow(new AmazonServiceException("wanted error"));
    // replacedert
    replacedertThatThrownBy(() -> messageChannel.send(stringMessage)).isInstanceOf(MessagingException.clreplaced).hasMessageContaining("wanted error");
}

19 Source : EventPublisher.java
with MIT License
from apssouza22

public void stream(AppEvent event) {
    Message<AppEvent> msg = MessageBuilder.withPayload(event).setHeader("type", event.getClreplaced().getSimpleName()).build();
    channel.send(msg);
    System.out.println("published");
}

19 Source : MyProducer.java
with Apache License 2.0
from Activiti

public void send(CloudRuntimeEvent<?, ?>... newEvents) {
    producer.send(MessageBuilder.withPayload(newEvents).build());
}

18 Source : PaymentDistributionApi.java
with MIT License
from youhusky

@RequestMapping(value = "/payments", method = RequestMethod.POST)
public void pay(@RequestBody Payment payment) {
    output.send(MessageBuilder.withPayload(payment).build());
}

18 Source : GenericMessagingTemplateTests.java
with MIT License
from Vip-Augus

private MessageHandler createLateReplier(final CountDownLatch latch, final AtomicReference<Throwable> failure) {
    MessageHandler handler = message -> {
        try {
            Thread.sleep(500);
            MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
            replyChannel.send(new GenericMessage<>("response"));
            failure.set(new IllegalStateException("Expected exception"));
        } catch (InterruptedException e) {
            failure.set(e);
        } catch (MessageDeliveryException ex) {
            String expected = "Reply message received but the receiving thread has exited due to a timeout";
            String actual = ex.getMessage();
            if (!expected.equals(actual)) {
                failure.set(new IllegalStateException("Unexpected error: '" + actual + "'"));
            }
        } finally {
            latch.countDown();
        }
    };
    return handler;
}

18 Source : CiDroidActionsController.java
with Apache License 2.0
from societe-generale

@PostMapping(path = "bulkUpdates")
@ResponseBody
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Perform an action in bulk, ie replicate it in all the resources mentioned in the command")
public ResponseEnreplacedy<?> onBulkUpdateRequest(@RequestBody @Valid @ApiParam(value = "The command describing the action to perform in bulk", required = true) BulkUpdateCommand bulkUpdateCommand) {
    log.info("received a bulkUpdateCommand {}", bulkUpdateCommand);
    publishMonitoringEventForBulkActionRequested(bulkUpdateCommand);
    for (ResourceToUpdate resourceToUpdate : bulkUpdateCommand.getResourcesToUpdate()) {
        BulkUpdateCommand singleResourceUpdateCommand = BulkUpdateCommand.builder().gitHubOauthToken(bulkUpdateCommand.getGitHubOauthToken()).email(bulkUpdateCommand.getEmail()).gitHubInteractionType(bulkUpdateCommand.getGitHubInteractionType()).updateAction(bulkUpdateCommand.getUpdateAction()).commitMessage(bulkUpdateCommand.getCommitMessage()).resourcesToUpdate(Arrays.asList(resourceToUpdate)).build();
        log.info("sending singleResourceUpdateCommand for processing {}...", singleResourceUpdateCommand);
        ciDroidActionsChannel.send(MessageBuilder.withPayload(singleResourceUpdateCommand).build());
    }
    return ResponseEnreplacedy.accepted().build();
}

18 Source : AbstractSourceControlWebHookController.java
with Apache License 2.0
from societe-generale

ResponseEnreplacedy<?> processPullRequestEvent(PullRequestEvent pullRequestEvent) {
    if (shouldNotProcess(pullRequestEvent)) {
        return ResponseEnreplacedy.accepted().build();
    }
    Message rawPullRequestEventMessage = MessageBuilder.withPayload(pullRequestEvent.getRawMessage().getBody()).build();
    log.info("sending to consumers : MergeRequestEvent for PR #{} on repo {}", pullRequestEvent.getPrNumber(), pullRequestEvent.getRepository().getName());
    pullRequestEventChannel.send(rawPullRequestEventMessage);
    return ResponseEnreplacedy.accepted().build();
}

18 Source : ProviderService.java
with GNU Affero General Public License v3.0
from romeoblog

public <T> void sendObject(T msg, String tag) {
    Message message = MessageBuilder.withPayload(msg).setHeader(MessageConst.PROPERTY_TAGS, tag).setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON).build();
    output.send(message);
}

18 Source : MessageProviderImpl.java
with MIT License
from moxi624

@Override
public String send() {
    String serial = UUID.randomUUID().toString();
    output.send(MessageBuilder.withPayload(serial).build());
    System.out.println("*****serial: " + serial);
    return null;
}

18 Source : MessageProviderImpl.java
with Apache License 2.0
from liusCoding

@Override
public String send() {
    String serial = UUID.randomUUID().toString();
    output.send(MessageBuilder.withPayload(serial).build());
    System.out.println("****************serial:" + serial);
    return serial;
}

18 Source : PubSubRecordItemListener.java
with Apache License 2.0
from hashgraph

// Publishes the PubSubMessage while retrying if a retryable error is encountered.
private void sendPubSubMessage(PubSubMessage pubSubMessage) {
    for (int numTries = 0; numTries < pubSubProperties.getMaxSendAttempts(); numTries++) {
        try {
            pubsubOutputChannel.send(MessageBuilder.withPayload(pubSubMessage).setHeader("consensusTimestamp", pubSubMessage.getConsensusTimestamp()).build());
        } catch (MessageTimeoutException e) {
            log.warn("Attempt {} to send message to PubSub timed out", numTries + 1);
            continue;
        }
        return;
    }
}

18 Source : MessageSender.java
with Apache License 2.0
from berndruecker

public void send(Message<?> m) {
    try {
        // avoid too much magic and transform ourselves
        String jsonMessage = objectMapper.writeValuereplacedtring(m);
        // wrap into a proper message for the transport (Kafka/Rabbit) and send it
        output.send(MessageBuilder.withPayload(jsonMessage).setHeader("type", m.getType()).build());
    } catch (Exception e) {
        throw new RuntimeException("Could not tranform and send message due to: " + e.getMessage(), e);
    }
}

18 Source : IntegrationRequestSender.java
with Apache License 2.0
from Activiti

private void sendAuditEvent(IntegrationRequest integrationRequest) {
    if (runtimeBundleProperties.getEventsProperties().isIntegrationAuditEventsEnabled()) {
        CloudIntegrationRequestedEventImpl integrationRequested = new CloudIntegrationRequestedEventImpl(integrationRequest.getIntegrationContext());
        runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(integrationRequested);
        Message<CloudRuntimeEvent<?, ?>[]> message = messageBuilderFactory.create(integrationRequest.getIntegrationContext()).withPayload(Stream.of(integrationRequested).toArray(CloudRuntimeEvent<?, ?>[]::new)).build();
        auditProducer.send(message);
    }
}

18 Source : IntegrationRequestSender.java
with Apache License 2.0
from Activiti

// send audit event is included in the the transaction because the audit chanel is transacted
@TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT)
public void sendAuditEvent(IntegrationRequest integrationRequest) {
    if (runtimeBundleProperties.getEventsProperties().isIntegrationAuditEventsEnabled()) {
        CloudIntegrationRequestedEventImpl integrationRequested = new CloudIntegrationRequestedEventImpl(integrationRequest.getIntegrationContext());
        runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(integrationRequested);
        CloudRuntimeEvent<?, ?>[] payload = Stream.of(integrationRequested).toArray(CloudRuntimeEvent[]::new);
        Message<CloudRuntimeEvent<?, ?>[]> message = messageBuilderFactory.create(integrationRequested.getEnreplacedy()).withPayload(payload).build();
        auditProducer.send(message);
    }
}

18 Source : GraphQLBrokerSubProtocolHandlerTest.java
with Apache License 2.0
from Activiti

@BeforeEach
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    this.testSubject = new GraphQLBrokerSubProtocolHandler("/ws/graphql");
    this.testSubject.setApplicationEventPublisher(applicationEventPublisher);
    when(outputChannel.send(any(Message.clreplaced))).thenReturn(true);
}

18 Source : IntegrationResultSenderImpl.java
with Apache License 2.0
from Activiti

@Override
public void send(Message<IntegrationResult> message) {
    IntegrationRequest request = message.getPayload().getIntegrationRequest();
    MessageChannel destination = resolver.resolveDestination(request);
    destination.send(message);
}

18 Source : IntegrationErrorSenderImpl.java
with Apache License 2.0
from Activiti

@Override
public void send(Message<IntegrationError> message) {
    IntegrationRequest request = message.getPayload().getIntegrationRequest();
    MessageChannel destination = resolver.resolveDestination(request);
    destination.send(message);
}

17 Source : StompSubProtocolHandler.java
with MIT License
from Vip-Augus

@Override
public void afterSessionEnded(WebSocketSession session, CloseStatus closeStatus, MessageChannel outputChannel) {
    this.decoders.remove(session.getId());
    Message<byte[]> message = createDisconnectMessage(session);
    SimpAttributes simpAttributes = SimpAttributes.fromMessage(message);
    try {
        SimpAttributesContextHolder.setAttributes(simpAttributes);
        if (this.eventPublisher != null) {
            Principal user = getUser(session);
            publishEvent(this.eventPublisher, new SessionDisconnectEvent(this, message, session.getId(), closeStatus, user));
        }
        outputChannel.send(message);
    } finally {
        this.stompAuthentications.remove(session.getId());
        SimpAttributesContextHolder.resetAttributes();
        simpAttributes.sessionCompleted();
    }
}

17 Source : AbstractSourceControlWebHookController.java
with Apache License 2.0
from societe-generale

protected ResponseEnreplacedy<?> processPushEvent(PushEvent pushEvent) {
    if (shouldNotProcess(pushEvent)) {
        return ResponseEnreplacedy.accepted().build();
    }
    String repoDefaultBranch = pushEvent.getRepository().getDefaultBranch();
    String eventRef = pushEvent.getRef();
    Message rawPushEventMessage = MessageBuilder.withPayload(pushEvent.getRawMessage().getBody()).build();
    if (eventRef.endsWith(repoDefaultBranch)) {
        log.info("sending to consumers : Pushevent on default branch {} on repo {}", repoDefaultBranch, pushEvent.getRepository().getFullName());
        pushOnDefaultBranchChannel.send(rawPushEventMessage);
    } else if (processNonDefaultBranchEvents) {
        log.info("sending to consumers : Pushevent on NON default branch {} on repo {}", repoDefaultBranch, pushEvent.getRepository().getName());
        pushOnNonDefaultBranchChannel.send(rawPushEventMessage);
    } else {
        log.info("Not sending pushevent on NON default branch {} on repo {}", repoDefaultBranch, pushEvent.getRepository().getFullName());
    }
    return ResponseEnreplacedy.accepted().build();
}

17 Source : ProviderService.java
with GNU Affero General Public License v3.0
from romeoblog

public Boolean send(MqMessageDTO messageDTO) {
    log.info("RECEIVE_MQ_MSG, msgDto={}", messageDTO);
    MessageBuilder<@NonNull String> messageBuilder = MessageBuilder.withPayload(messageDTO.getBody());
    messageBuilder.setHeader(RocketMQHeaders.TAGS, messageDTO.getTag());
    messageBuilder.setHeader(RocketMQHeaders.KEYS, messageDTO.getKey());
    if (messageDTO.getDelayTimeLevel() != null && messageDTO.getDelayTimeLevel() > 0) {
        messageBuilder.setHeader("DELAY", messageDTO.getDelayTimeLevel().toString());
    }
    Message message = messageBuilder.build();
    output.send(message);
    log.info("SEND_MQ_MSG_SUCCESS, messageDTO={}", messageDTO);
    return true;
}

17 Source : AbstractEvent.java
with MIT License
from msa-ez

public void publish(String json) {
    if (json != null) {
        /**
         * spring streams 방식
         */
        KafkaProcessor processor = Application.applicationContext.getBean(KafkaProcessor.clreplaced);
        MessageChannel outputChannel = processor.outboundTopic();
        outputChannel.send(MessageBuilder.withPayload(json).setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON).build());
    }
}

17 Source : StompSubProtocolHandler.java
with Apache License 2.0
from langtianya

@Override
@SuppressWarnings("deprecation")
public void afterSessionEnded(WebSocketSession session, CloseStatus closeStatus, MessageChannel outputChannel) {
    this.decoders.remove(session.getId());
    Principal principal = session.getPrincipal();
    if (principal != null && this.userSessionRegistry != null) {
        String userName = getSessionRegistryUserName(principal);
        this.userSessionRegistry.unregisterSessionId(userName, session.getId());
    }
    Message<byte[]> message = createDisconnectMessage(session);
    SimpAttributes simpAttributes = SimpAttributes.fromMessage(message);
    try {
        SimpAttributesContextHolder.setAttributes(simpAttributes);
        if (this.eventPublisher != null) {
            Principal user = session.getPrincipal();
            publishEvent(new SessionDisconnectEvent(this, message, session.getId(), closeStatus, user));
        }
        outputChannel.send(message);
    } finally {
        SimpAttributesContextHolder.resetAttributes();
        simpAttributes.sessionCompleted();
    }
}

17 Source : Stomp.java
with Apache License 2.0
from codeabovelab

/**
 * Send message to queue of current session
 * @param subscriptionId
 * @param dest
 * @param msg
 */
public void sendToSubscription(String subscriptionId, String dest, Object msg) {
    replacedert.notNull(subscriptionId, "subscriptionId is null");
    StompHeaderAccessor sha = createHeaders(sessionId, subscriptionId);
    MessageConverter messageConverter = this.template.getMessageConverter();
    sha.setDestination("/queue/" + dest);
    Message<?> message = messageConverter.toMessage(msg, sha.getMessageHeaders());
    clientChannel.send(message);
}

17 Source : SpringJmsApplicationTest.java
with MIT License
from code-not-found

@Test
public void testIntegration() throws Exception {
    MessageChannel producingChannel = applicationContext.getBean("producingChannel", MessageChannel.clreplaced);
    Map<String, Object> headers = Collections.singletonMap(JmsHeaders.DESTINATION, integrationDestination);
    LOGGER.info("sending 10 messages");
    for (int i = 0; i < 10; i++) {
        GenericMessage<String> message = new GenericMessage<>("Hello Spring Integration JMS " + i + "!", headers);
        producingChannel.send(message);
        LOGGER.info("sent message='{}'", message);
    }
    countDownLatchHandler.getLatch().await(10000, TimeUnit.MILLISECONDS);
    replacedertThat(countDownLatchHandler.getLatch().getCount()).isEqualTo(0);
}

17 Source : ServiceTaskIntegrationResultEventHandler.java
with Apache License 2.0
from Activiti

private void sendAuditMessage(IntegrationResult integrationResult) {
    if (runtimeBundleProperties.getEventsProperties().isIntegrationAuditEventsEnabled()) {
        CloudIntegrationResultReceivedEventImpl integrationResultReceived = new CloudIntegrationResultReceivedEventImpl(integrationResult.getIntegrationContext());
        runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(integrationResultReceived);
        Message<CloudRuntimeEvent<?, ?>[]> message = MessageBuilder.withPayload(Stream.of(integrationResultReceived).toArray(CloudRuntimeEvent<?, ?>[]::new)).build();
        auditProducer.send(message);
    }
}

17 Source : GraphQLBrokerSubProtocolHandler.java
with Apache License 2.0
from Activiti

@Override
public void afterSessionEnded(WebSocketSession session, CloseStatus closeStatus, MessageChannel outputChannel) throws Exception {
    this.stats.incrementDisconnectCount();
    /*
         * To cleanup we send an internal messages to the handlers. It might be possible
         * that this is an unexpected session end and the client did not unsubscribe his
         * subscriptions.
         */
    Message<GraphQLMessage> message = createDisconnectMessage(session);
    try {
        SimpAttributesContextHolder.setAttributesFromMessage(message);
        if (this.eventPublisher != null) {
            Principal user = getUser(session);
            publishEvent(new GraphQLSessionDisconnectEvent(this, message, session.getId(), closeStatus, user));
        }
        outputChannel.send(message);
    } finally {
        this.graphqlAuthentications.remove(session.getId());
        SimpAttributesContextHolder.resetAttributes();
    }
}

17 Source : GraphQLBrokerChannelSubscriber.java
with Apache License 2.0
from Activiti

protected void sendDataToClient(Object data) {
    Map<String, Object> payload = Collections.singletonMap("data", data);
    GraphQLMessage operationData = new GraphQLMessage(operationMessageId, GraphQLMessageType.DATA, payload);
    Message<?> responseMessage = MessageBuilder.createMessage(operationData, getMessageHeaders());
    // Send message directly to user
    outboundChannel.send(responseMessage);
}

17 Source : GraphQLBrokerChannelSubscriber.java
with Apache License 2.0
from Activiti

@Override
public void onComplete() {
    log.info("Subscription complete: {}", subscriptionRef.get());
    cancel();
    GraphQLMessage operationMessage = new GraphQLMessage(operationMessageId, GraphQLMessageType.COMPLETE);
    Message<?> responseMessage = MessageBuilder.createMessage(operationMessage, getMessageHeaders());
    outboundChannel.send(responseMessage);
}

16 Source : EventRouter.java
with Apache License 2.0
from codeabovelab

private void sendHistoryToNewSubscriber(AbstractSubProtocolEvent ev) {
    Message<byte[]> msg = ev.getMessage();
    StompHeaderAccessor ha = StompHeaderAccessor.wrap(msg);
    String pattern = ha.getDestination();
    if (!pattern.startsWith(PREFIX)) {
        // we must send only to appropriate paths
        return;
    }
    MessageConverter messageConverter = this.simpMessagingTemplate.getMessageConverter();
    for (BusData data : buses.values()) {
        String dest = getDestination(data.getId());
        if (!this.pathMatcher.match(pattern, dest)) {
            continue;
        }
        for (Object obj : data.getEvents()) {
            StompHeaderAccessor mha = Stomp.createHeaders(ha.getSessionId(), ha.getSubscriptionId());
            mha.setDestination(dest);
            Message<?> message = messageConverter.toMessage(obj, mha.getMessageHeaders());
            clientChannel.send(message);
        }
    }
}

16 Source : SpringJmsApplicationTest.java
with MIT License
from code-not-found

@Test
public void testIntegrationGateway() {
    MessageChannel outboundOrderRequestChannel = applicationContext.getBean("outboundOrderRequestChannel", MessageChannel.clreplaced);
    QueueChannel outboundOrderResponseChannel = applicationContext.getBean("outboundOrderResponseChannel", QueueChannel.clreplaced);
    outboundOrderRequestChannel.send(new GenericMessage<>("order-001"));
    replacedertThat(outboundOrderResponseChannel.receive(5000).getPayload()).isEqualTo("Accepted");
    ;
}

15 Source : BillingEventHandler.java
with MIT License
from PacktPublishing

public void produceBillingEvent(Billing billing, String bookingName) {
    final BillingBookingResponse.Builder responseBuilder = BillingBookingResponse.newBuilder();
    if (billing != null) {
        responseBuilder.setBillId(billing.getId());
        responseBuilder.setBookingId(bookingName);
        responseBuilder.setName(billing.getName());
        responseBuilder.setRestaurantId(billing.getRestaurantId());
        responseBuilder.setTableId(billing.getTableId());
        responseBuilder.setStatus("BILLING_DONE");
        responseBuilder.setDate(billing.getDate().toString());
        responseBuilder.setTime(billing.getTime().toString());
    } else {
        // You could also raise another event with error response
        // for keeping code and logic same event is used for failed event as a workaround
        responseBuilder.setBillId("");
        responseBuilder.setBookingId(bookingName);
        responseBuilder.setName("");
        responseBuilder.setRestaurantId("");
        responseBuilder.setTableId("");
        responseBuilder.setDate("");
        responseBuilder.setTime("");
        responseBuilder.setStatus("BILLING_FAILED");
    }
    BillingBookingResponse response = responseBuilder.build();
    final Message<BillingBookingResponse> message = MessageBuilder.withPayload(response).setHeader("Content-Type", "application/*+avro").build();
    billingMessageChannel.send(message);
}

15 Source : PubSubRecordItemListenerTest.java
with Apache License 2.0
from hashgraph

@Test
void testSendRetries() throws Exception {
    // when
    CryptoTransferTransactionBody cryptoTransfer = CryptoTransferTransactionBody.newBuilder().setTransfers(TransferList.newBuilder().build()).build();
    Transaction transaction = buildTransaction(builder -> builder.setCryptoTransfer(cryptoTransfer));
    pubSubProperties.setMaxSendAttempts(3);
    // when
    when(messageChannel.send(any())).thenThrow(MessageTimeoutException.clreplaced).thenThrow(MessageTimeoutException.clreplaced).thenReturn(true);
    pubSubRecordItemListener.onItem(new RecordItem(transaction.toByteArray(), DEFAULT_RECORD_BYTES));
    // then
    var pubSubMessage = replacedertPubSubMessage(buildPubSubTransaction(transaction), 3);
    replacedertThat(pubSubMessage.getEnreplacedy()).isNull();
    replacedertThat(pubSubMessage.getNonFeeTransfers()).isNull();
}

15 Source : PubSubRecordItemListenerTest.java
with Apache License 2.0
from hashgraph

@Test
void testNonRetryableError() {
    // when
    CryptoTransferTransactionBody cryptoTransfer = CryptoTransferTransactionBody.newBuilder().setTransfers(TransferList.newBuilder().build()).build();
    Transaction transaction = buildTransaction(builder -> builder.setCryptoTransfer(cryptoTransfer));
    // when
    when(messageChannel.send(any())).thenThrow(RuntimeException.clreplaced);
    // then
    replacedertThatThrownBy(() -> pubSubRecordItemListener.onItem(new RecordItem(transaction.toByteArray(), DEFAULT_RECORD_BYTES))).isInstanceOf(ParserException.clreplaced).hasMessageContaining("Error sending transaction to pubsub");
    verify(messageChannel, times(1)).send(any());
}

15 Source : SpringKafkaIntegrationApplicationTest.java
with MIT License
from code-not-found

@Test
public void testIntegration() throws Exception {
    MessageChannel producingChannel = applicationContext.getBean("producingChannel", MessageChannel.clreplaced);
    Map<String, Object> headers = Collections.singletonMap(KafkaHeaders.TOPIC, SPRING_INTEGRATION_KAFKA_TOPIC);
    LOGGER.info("sending 10 messages");
    for (int i = 0; i < 10; i++) {
        GenericMessage<String> message = new GenericMessage<>("Hello Spring Integration Kafka " + i + "!", headers);
        producingChannel.send(message);
        LOGGER.info("sent message='{}'", message);
    }
    countDownLatchHandler.getLatch().await(10000, TimeUnit.MILLISECONDS);
    replacedertThat(countDownLatchHandler.getLatch().getCount()).isEqualTo(0);
}

15 Source : GraphQLBrokerChannelSubscriber.java
with Apache License 2.0
from Activiti

@Override
public void onError(Throwable t) {
    log.error("Subscription {} threw an exception {}", subscriptionRef.get(), t);
    Map<String, Object> payload = Collections.singletonMap("errors", Collections.singletonList(t.getMessage()));
    GraphQLMessage operationMessage = new GraphQLMessage(operationMessageId, GraphQLMessageType.ERROR, payload);
    Message<GraphQLMessage> responseMessage = MessageBuilder.createMessage(operationMessage, getMessageHeaders());
    outboundChannel.send(responseMessage);
}

14 Source : MessageBrokerConfigurationTests.java
with MIT License
from Vip-Augus

private void testDotSeparator(ApplicationContext context, boolean expectLeadingSlash) {
    MessageChannel inChannel = context.getBean("clientInboundChannel", MessageChannel.clreplaced);
    TestChannel outChannel = context.getBean("clientOutboundChannel", TestChannel.clreplaced);
    MessageChannel brokerChannel = context.getBean("brokerChannel", MessageChannel.clreplaced);
    inChannel.send(createConnectMessage("sess1", new long[] { 0, 0 }));
    // 1. Subscribe to user destination
    StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
    headers.setSessionId("sess1");
    headers.setSubscriptionId("subs1");
    headers.setDestination("/user/queue.q1");
    Message<?> message = MessageBuilder.createMessage(new byte[0], headers.getMessageHeaders());
    inChannel.send(message);
    // 2. Send message to user via inboundChannel
    headers = StompHeaderAccessor.create(StompCommand.SEND);
    headers.setSessionId("sess1");
    headers.setDestination("/user/sess1/queue.q1");
    message = MessageBuilder.createMessage("123".getBytes(), headers.getMessageHeaders());
    inChannel.send(message);
    replacedertEquals(2, outChannel.messages.size());
    Message<?> outputMessage = outChannel.messages.remove(1);
    headers = StompHeaderAccessor.wrap(outputMessage);
    replacedertEquals(SimpMessageType.MESSAGE, headers.getMessageType());
    replacedertEquals(expectLeadingSlash ? "/queue.q1-usersess1" : "queue.q1-usersess1", headers.getDestination());
    replacedertEquals("123", new String((byte[]) outputMessage.getPayload()));
    outChannel.messages.clear();
    // 3. Send message via broker channel
    SimpMessagingTemplate template = new SimpMessagingTemplate(brokerChannel);
    SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create();
    accessor.setSessionId("sess1");
    template.convertAndSendToUser("sess1", "queue.q1", "456".getBytes(), accessor.getMessageHeaders());
    replacedertEquals(1, outChannel.messages.size());
    outputMessage = outChannel.messages.remove(0);
    headers = StompHeaderAccessor.wrap(outputMessage);
    replacedertEquals(SimpMessageType.MESSAGE, headers.getMessageType());
    replacedertEquals(expectLeadingSlash ? "/queue.q1-usersess1" : "queue.q1-usersess1", headers.getDestination());
    replacedertEquals("456", new String((byte[]) outputMessage.getPayload()));
}

14 Source : MessageBrokerConfigurationTests.java
with Apache License 2.0
from SourceHot

private void testDotSeparator(ApplicationContext context, boolean expectLeadingSlash) {
    MessageChannel inChannel = context.getBean("clientInboundChannel", MessageChannel.clreplaced);
    TestChannel outChannel = context.getBean("clientOutboundChannel", TestChannel.clreplaced);
    MessageChannel brokerChannel = context.getBean("brokerChannel", MessageChannel.clreplaced);
    inChannel.send(createConnectMessage("sess1", new long[] { 0, 0 }));
    // 1. Subscribe to user destination
    StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
    headers.setSessionId("sess1");
    headers.setSubscriptionId("subs1");
    headers.setDestination("/user/queue.q1");
    Message<?> message = MessageBuilder.createMessage(new byte[0], headers.getMessageHeaders());
    inChannel.send(message);
    // 2. Send message to user via inboundChannel
    headers = StompHeaderAccessor.create(StompCommand.SEND);
    headers.setSessionId("sess1");
    headers.setDestination("/user/sess1/queue.q1");
    message = MessageBuilder.createMessage("123".getBytes(), headers.getMessageHeaders());
    inChannel.send(message);
    replacedertThat(outChannel.messages.size()).isEqualTo(2);
    Message<?> outputMessage = outChannel.messages.remove(1);
    headers = StompHeaderAccessor.wrap(outputMessage);
    replacedertThat(headers.getMessageType()).isEqualTo(SimpMessageType.MESSAGE);
    Object expecteds1 = expectLeadingSlash ? "/queue.q1-usersess1" : "queue.q1-usersess1";
    replacedertThat(headers.getDestination()).isEqualTo(expecteds1);
    replacedertThat(new String((byte[]) outputMessage.getPayload())).isEqualTo("123");
    outChannel.messages.clear();
    // 3. Send message via broker channel
    SimpMessagingTemplate template = new SimpMessagingTemplate(brokerChannel);
    SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create();
    accessor.setSessionId("sess1");
    template.convertAndSendToUser("sess1", "queue.q1", "456".getBytes(), accessor.getMessageHeaders());
    replacedertThat(outChannel.messages.size()).isEqualTo(1);
    outputMessage = outChannel.messages.remove(0);
    headers = StompHeaderAccessor.wrap(outputMessage);
    replacedertThat(headers.getMessageType()).isEqualTo(SimpMessageType.MESSAGE);
    Object expecteds = expectLeadingSlash ? "/queue.q1-usersess1" : "queue.q1-usersess1";
    replacedertThat(headers.getDestination()).isEqualTo(expecteds);
    replacedertThat(new String((byte[]) outputMessage.getPayload())).isEqualTo("456");
}

14 Source : ActivitiCloudConnectorServiceIT.java
with Apache License 2.0
from Activiti

@Test
public void integrationErrorShouldBeProducedByConnectorCloudBpmnErrorMock() throws Exception {
    // given
    streamHandler.isIntegrationErrorEventProduced().set(false);
    IntegrationRequest integrationRequest = mockIntegrationRequest();
    Message<IntegrationRequest> message = MessageBuilder.withPayload(integrationRequest).setHeader(INTEGRATION_CONTEXT_ID, UUID.randomUUID().toString()).setHeader("type", "CloudBpmnError").build();
    integrationEventsProducer.send(message);
    await("Should produce CloudBpmnError integration error").untilTrue(streamHandler.isIntegrationErrorEventProduced());
    IntegrationError integrationError = streamHandler.getIntegrationError();
    replacedertThat(integrationError.getErrorClreplacedName()).isEqualTo(CloudBpmnError.clreplaced.getName());
    replacedertThat(integrationError.getErrorCode()).isEqualTo("ERROR_CODE");
    replacedertThat(integrationError.getErrorMessage()).isEqualTo("ERROR_CODE");
    replacedertThat(integrationError.getStackTraceElements()).asList().isNotEmpty().extracting("methodName").contains("mockTypeIntegrationCloudBpmnErrorSender").doesNotContain("raiseErrorCause");
    replacedertThat(integrationError.getIntegrationContext().getId()).isEqualTo(INTEGRATION_ID);
}

14 Source : ActivitiCloudConnectorServiceIT.java
with Apache License 2.0
from Activiti

@Test
public void integrationErrorShouldBeProducedByConnectorRuntimeExceptionMock() throws Exception {
    // given
    streamHandler.isIntegrationErrorEventProduced().set(false);
    IntegrationRequest integrationRequest = mockIntegrationRequest();
    Message<IntegrationRequest> message = MessageBuilder.withPayload(integrationRequest).setHeader(INTEGRATION_CONTEXT_ID, UUID.randomUUID().toString()).setHeader("type", "RuntimeException").build();
    integrationEventsProducer.send(message);
    await("Should produce RuntimeException integration error").untilTrue(streamHandler.isIntegrationErrorEventProduced());
    IntegrationError integrationError = streamHandler.getIntegrationError();
    replacedertThat(integrationError.getErrorClreplacedName()).isEqualTo("java.lang.RuntimeException");
    replacedertThat(integrationError.getErrorMessage()).isEqualTo("Mock RuntimeException");
    replacedertThat(integrationError.getStackTraceElements()).asList().isNotEmpty();
    replacedertThat(integrationError.getIntegrationContext().getId()).isEqualTo(INTEGRATION_ID);
}

14 Source : ActivitiCloudConnectorServiceIT.java
with Apache License 2.0
from Activiti

@Test
public void integrationErrorShouldBeProducedByConnectorCloudBpmnErrorMessageMock() throws Exception {
    // given
    streamHandler.isIntegrationErrorEventProduced().set(false);
    IntegrationRequest integrationRequest = mockIntegrationRequest();
    Message<IntegrationRequest> message = MessageBuilder.withPayload(integrationRequest).setHeader(INTEGRATION_CONTEXT_ID, UUID.randomUUID().toString()).setHeader("type", "CloudBpmnErrorMessage").build();
    integrationEventsProducer.send(message);
    await("Should produce CloudBpmnError with error code and message integration error").untilTrue(streamHandler.isIntegrationErrorEventProduced());
    IntegrationError integrationError = streamHandler.getIntegrationError();
    replacedertThat(integrationError.getErrorClreplacedName()).isEqualTo(CloudBpmnError.clreplaced.getName());
    replacedertThat(integrationError.getErrorCode()).isEqualTo("ERROR_CODE");
    replacedertThat(integrationError.getErrorMessage()).isEqualTo("Error code message");
    replacedertThat(integrationError.getStackTraceElements()).asList().isNotEmpty().extracting("methodName").contains("mockTypeIntegrationCloudBpmnErrorMessageSender").doesNotContain("raiseErrorCause");
    replacedertThat(integrationError.getIntegrationContext().getId()).isEqualTo(INTEGRATION_ID);
}

14 Source : ActivitiCloudConnectorServiceIT.java
with Apache License 2.0
from Activiti

@Test
public void integrationErrorShouldBeProducedByConnectorCloudBpmnErrorCauseMock() throws Exception {
    // given
    streamHandler.isIntegrationErrorEventProduced().set(false);
    IntegrationRequest integrationRequest = mockIntegrationRequest();
    Message<IntegrationRequest> message = MessageBuilder.withPayload(integrationRequest).setHeader(INTEGRATION_CONTEXT_ID, UUID.randomUUID().toString()).setHeader("type", "CloudBpmnErrorCause").build();
    integrationEventsProducer.send(message);
    await("Should produce CloudBpmnError with root cause and message integration error").untilTrue(streamHandler.isIntegrationErrorEventProduced());
    IntegrationError integrationError = streamHandler.getIntegrationError();
    replacedertThat(integrationError.getErrorClreplacedName()).isEqualTo(CloudBpmnError.clreplaced.getName());
    replacedertThat(integrationError.getErrorCode()).isEqualTo("ERROR_CODE");
    replacedertThat(integrationError.getErrorMessage()).isEqualTo("Error cause message");
    replacedertThat(integrationError.getStackTraceElements()).asList().isNotEmpty().extracting("methodName").contains("raiseErrorCause", "mockTypeIntegrationCloudBpmnErrorRootCauseSender");
    replacedertThat(integrationError.getIntegrationContext().getId()).isEqualTo(INTEGRATION_ID);
}

14 Source : ActivitiCloudConnectorServiceIT.java
with Apache License 2.0
from Activiti

@Test
public void integrationErrorShouldBeProducedByConnectorErrorMock() throws Exception {
    // given
    streamHandler.isIntegrationErrorEventProduced().set(false);
    IntegrationRequest integrationRequest = mockIntegrationRequest();
    Message<IntegrationRequest> message = MessageBuilder.withPayload(integrationRequest).setHeader(INTEGRATION_CONTEXT_ID, UUID.randomUUID().toString()).setHeader("type", "Error").build();
    integrationEventsProducer.send(message);
    await("Should produce Error integration error").untilTrue(streamHandler.isIntegrationErrorEventProduced());
    IntegrationError integrationError = streamHandler.getIntegrationError();
    replacedertThat(integrationError.getErrorClreplacedName()).isEqualTo("java.lang.Error");
    replacedertThat(integrationError.getErrorMessage()).isEqualTo("Mock Error");
    replacedertThat(integrationError.getStackTraceElements()).asList().isNotEmpty();
    replacedertThat(integrationError.getIntegrationContext().getId()).isEqualTo(INTEGRATION_ID);
}

13 Source : ServiceTaskIntegrationErrorEventHandler.java
with Apache License 2.0
from Activiti

private void sendAuditMessage(IntegrationError integrationError) {
    if (runtimeBundleProperties.getEventsProperties().isIntegrationAuditEventsEnabled()) {
        CloudIntegrationErrorReceivedEventImpl integrationErrorReceived = new CloudIntegrationErrorReceivedEventImpl(integrationError.getIntegrationContext(), integrationError.getErrorCode(), integrationError.getErrorMessage(), integrationError.getErrorClreplacedName(), integrationError.getStackTraceElements());
        runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(integrationErrorReceived);
        CloudRuntimeEvent<?, ?>[] payload = Stream.of(integrationErrorReceived).toArray(CloudRuntimeEvent[]::new);
        Message<CloudRuntimeEvent<?, ?>[]> message = messageBuilderFactory.create(integrationErrorReceived.getEnreplacedy()).withPayload(payload).build();
        auditProducer.send(message);
    }
}

12 Source : ServiceTaskIntegrationResultEventHandler.java
with Apache License 2.0
from Activiti

private void sendAuditMessage(IntegrationResult integrationResult) {
    if (runtimeBundleProperties.getEventsProperties().isIntegrationAuditEventsEnabled()) {
        CloudIntegrationResultReceivedEventImpl integrationResultReceived = new CloudIntegrationResultReceivedEventImpl(integrationResult.getIntegrationContext());
        runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(integrationResultReceived);
        CloudRuntimeEvent<?, ?>[] payload = Stream.of(integrationResultReceived).toArray(CloudRuntimeEvent[]::new);
        Message<CloudRuntimeEvent<?, ?>[]> message = messageBuilderFactory.create(integrationResult.getIntegrationContext()).withPayload(payload).build();
        auditProducer.send(message);
    }
}

See More Examples