public class ActivityReceiver<T> implements MessageReceiver{
@Autowired
BeanFinder beanFinder;
@Override
public void receiveMessage(PubsubMessage message, AckReplyConsumer consumer) {
System.out.println("Id: " + message.getMessageId());
CloudEventImpl<T> ce = CloudEventMapper.mapToGenericCloudEvent(message);
System.out.println("Data: " + ce.getAttributes().getType() +" "+ ce.getData());
IAbstractEventProcessor<PubsubMessage> eventProcessor = beanFinder.get(CloudEventMapper.getEventType(ce).get().getEventName());
eventProcessor.execute(message);
consumer.ack();
}
}
--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/63df3bf2-f667-4965-a42c-f49e630c27d6n%40googlegroups.com.
@Component
public class ApplicationStartupRunner implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
Subscriber subscriber = Subscriber
.newBuilder(ProjectSubscriptionName.of("festive-utility-297015", "app-activity"), new ActivityReceiver()).build();
subscriber.startAsync().awaitRunning();
System.out.printf("Listening for messages on %s:\n",
ProjectSubscriptionName.of("festive-utility-297015", "app-activity").toString());
subscriber.awaitTerminated();
}
@Component
public class ApplicationStartupRunner implements ApplicationRunner {
@Autowired
ActivityReceiver activityReceiver;
@Override
public void run(ApplicationArguments args) throws Exception {
Subscriber subscriber = Subscriber
.newBuilder(ProjectSubscriptionName.of("festive-utility-297015", "app-activity"), activityReceiver).build();
subscriber.startAsync().awaitRunning();
System.out.printf("Listening for messages on %s:\n",
ProjectSubscriptionName.of("festive-utility-297015", "app-activity").toString());
subscriber.awaitTerminated();
}