org.springframework.cloud.bus.event.AckRemoteApplicationEvent Java Examples
The following examples show how to use
org.springframework.cloud.bus.event.AckRemoteApplicationEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BusAutoConfigurationTests.java From spring-cloud-bus with Apache License 2.0 | 6 votes |
@Test public void inboundAckWithTrace() throws Exception { this.context = SpringApplication.run( new Class[] { InboundMessageHandlerConfiguration.class, OutboundMessageHandlerConfiguration.class, AckMessageConfiguration.class }, new String[] { "--spring.cloud.bus.trace.enabled=true", "--spring.cloud.bus.id=bar", "--server.port=0" }); this.context.getBean(BusProperties.class).setId("bar"); this.context.getBean(SpringCloudBusClient.INPUT, MessageChannel.class) .send(new GenericMessage<>(new AckRemoteApplicationEvent(this, "foo", null, "ID", "bar", RefreshRemoteApplicationEvent.class))); AckMessageConfiguration sent = this.context .getBean(AckMessageConfiguration.class); assertThat(sent.event).isNotNull(); assertThat(sent.count).isEqualTo(1); }
Example #2
Source File: BusAutoConfiguration.java From spring-cloud-bus with Apache License 2.0 | 5 votes |
@EventListener(classes = RemoteApplicationEvent.class) public void acceptLocal(RemoteApplicationEvent event) { if (this.serviceMatcher.isFromSelf(event) && !(event instanceof AckRemoteApplicationEvent)) { if (log.isDebugEnabled()) { log.debug("Sending remote event on bus: " + event); } this.cloudBusOutboundChannel.send(MessageBuilder.withPayload(event).build()); } }
Example #3
Source File: BusAutoConfiguration.java From spring-cloud-bus with Apache License 2.0 | 5 votes |
@StreamListener(SpringCloudBusClient.INPUT) public void acceptRemote(RemoteApplicationEvent event) { if (event instanceof AckRemoteApplicationEvent) { if (this.bus.getTrace().isEnabled() && !this.serviceMatcher.isFromSelf(event) && this.applicationEventPublisher != null) { this.applicationEventPublisher.publishEvent(event); } // If it's an ACK we are finished processing at this point return; } if (log.isDebugEnabled()) { log.debug("Received remote event from bus: " + event); } if (this.serviceMatcher.isForSelf(event) && this.applicationEventPublisher != null) { if (!this.serviceMatcher.isFromSelf(event)) { this.applicationEventPublisher.publishEvent(event); } if (this.bus.getAck().isEnabled()) { AckRemoteApplicationEvent ack = new AckRemoteApplicationEvent(this, this.serviceMatcher.getServiceId(), this.bus.getAck().getDestinationService(), event.getDestinationService(), event.getId(), event.getClass()); this.cloudBusOutboundChannel .send(MessageBuilder.withPayload(ack).build()); this.applicationEventPublisher.publishEvent(ack); } } if (this.bus.getTrace().isEnabled() && this.applicationEventPublisher != null) { // We are set to register sent events so publish it for local consumption, // irrespective of the origin this.applicationEventPublisher.publishEvent(new SentApplicationEvent(this, event.getOriginService(), event.getDestinationService(), event.getId(), event.getClass())); } }
Example #4
Source File: SubtypeModuleTests.java From spring-cloud-bus with Apache License 2.0 | 5 votes |
/** * see https://github.com/spring-cloud/spring-cloud-bus/issues/74 */ @Test public void testDeserializeAckRemoteApplicationEventWithKnownType() throws Exception { BusJacksonMessageConverter converter = new BusJacksonMessageConverter(null); converter.afterPropertiesSet(); Object event = converter.fromMessage(MessageBuilder .withPayload("{\"type\":\"AckRemoteApplicationEvent\", " + "\"event\":\"org.springframework.cloud.bus.event.test.TestRemoteApplicationEvent\"}") .build(), RemoteApplicationEvent.class); assertThat(event instanceof AckRemoteApplicationEvent).as("event is no ack") .isTrue(); AckRemoteApplicationEvent ackEvent = AckRemoteApplicationEvent.class.cast(event); assertThat(ackEvent.getEvent()).as("inner ack event has wrong type") .isEqualTo(TestRemoteApplicationEvent.class); }
Example #5
Source File: SubtypeModuleTests.java From spring-cloud-bus with Apache License 2.0 | 5 votes |
/** * see https://github.com/spring-cloud/spring-cloud-bus/issues/74 */ @Test public void testDeserializeAckRemoteApplicationEventWithUnknownType() throws Exception { BusJacksonMessageConverter converter = new BusJacksonMessageConverter(null); converter.afterPropertiesSet(); Object event = converter.fromMessage(MessageBuilder.withPayload( "{\"type\":\"AckRemoteApplicationEvent\", \"event\":\"foo.bar.TestRemoteApplicationEvent\"}") .build(), RemoteApplicationEvent.class); assertThat(event instanceof AckRemoteApplicationEvent).as("event is no ack") .isTrue(); AckRemoteApplicationEvent ackEvent = AckRemoteApplicationEvent.class.cast(event); assertThat(ackEvent.getEvent()).as("inner ack event has wrong type") .isEqualTo(UnknownRemoteApplicationEvent.class); }
Example #6
Source File: RemoteApplicationEventScanTests.java From spring-cloud-bus with Apache License 2.0 | 5 votes |
private void addStandardSpringCloudEventBusEvents( final List<Class<?>> expectedRegisterdClassesAsList) { expectedRegisterdClassesAsList.add(AckRemoteApplicationEvent.class); expectedRegisterdClassesAsList.add(EnvironmentChangeRemoteApplicationEvent.class); expectedRegisterdClassesAsList.add(RefreshRemoteApplicationEvent.class); expectedRegisterdClassesAsList.add(UnknownRemoteApplicationEvent.class); }
Example #7
Source File: BusController.java From rocketmq-binder-demo with Apache License 2.0 | 4 votes |
@EventListener public void onAckEvent(AckRemoteApplicationEvent event) throws JsonProcessingException { System.out.printf("ServiceId [%s] listeners on %s\n", serviceId, objectMapper.writeValueAsString(event)); }
Example #8
Source File: BusController.java From rocketmq-binder-demo with Apache License 2.0 | 4 votes |
@EventListener public void onAckEvent(AckRemoteApplicationEvent event) throws JsonProcessingException { System.out.printf("ServiceId [%s] listeners on %s\n", serviceId, objectMapper.writeValueAsString(event)); }
Example #9
Source File: BusController.java From rocketmq-binder-demo with Apache License 2.0 | 4 votes |
@EventListener public void onAckEvent(AckRemoteApplicationEvent event) throws JsonProcessingException { System.out.printf("ServiceId [%s] listeners on %s\n", serviceId, objectMapper.writeValueAsString(event)); }
Example #10
Source File: BusController.java From rocketmq-binder-demo with Apache License 2.0 | 4 votes |
@EventListener public void onAckEvent(AckRemoteApplicationEvent event) throws JsonProcessingException { System.out.printf("ServiceId [%s] listeners on %s\n", serviceId, objectMapper.writeValueAsString(event)); }
Example #11
Source File: BusController.java From rocketmq-binder-demo with Apache License 2.0 | 4 votes |
@EventListener public void onAckEvent(AckRemoteApplicationEvent event) throws JsonProcessingException { System.out.printf("ServiceId [%s] listeners on %s\n", serviceId, objectMapper.writeValueAsString(event)); }
Example #12
Source File: RocketMQBusApplication.java From spring-cloud-alibaba with Apache License 2.0 | 4 votes |
@EventListener public void onAckEvent(AckRemoteApplicationEvent event) throws JsonProcessingException { System.out.printf("Server [port : %d] listeners on %s\n", localServerPort, objectMapper.writeValueAsString(event)); }
Example #13
Source File: BusAutoConfigurationTests.java From spring-cloud-bus with Apache License 2.0 | 4 votes |
@Override public void onApplicationEvent(AckRemoteApplicationEvent event) { this.event = event; this.count++; }