Skip to content

Commit

Permalink
More code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoandremartins committed Jul 13, 2017
1 parent f13fa3c commit 431123d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package com.example.spring.pubsub;

import com.google.pubsub.v1.Subscription;
import com.google.pubsub.v1.SubscriptionName;
import com.google.pubsub.v1.Topic;
import com.google.pubsub.v1.TopicName;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

import com.google.cloud.pubsub.v1.AckReplyConsumer;
import com.google.protobuf.ByteString;

import java.util.List;
import java.util.stream.Collectors;
import com.google.pubsub.v1.Subscription;
import com.google.pubsub.v1.SubscriptionName;
import com.google.pubsub.v1.Topic;
import com.google.pubsub.v1.TopicName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringApplication;
Expand All @@ -22,8 +22,6 @@
import org.springframework.cloud.gcp.pubsub.support.GcpHeaders;
import org.springframework.cloud.gcp.pubsub.support.SubscriberFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.integration.annotation.IntegrationComponentScan;
import org.springframework.integration.annotation.MessagingGateway;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.channel.PublishSubscribeChannel;
Expand All @@ -39,9 +37,7 @@
import org.springframework.web.servlet.view.RedirectView;

@SpringBootApplication
@IntegrationComponentScan
@RestController
@ComponentScan(basePackages = {"org.springframework.cloud.gcp"})
public class PubsubApplication {

private static final Log LOGGER = LogFactory.getLog(PubsubApplication.class);
Expand Down Expand Up @@ -110,7 +106,7 @@ public PubsubInboundChannelAdapter messageChannelAdapter(

@Bean
@ServiceActivator(inputChannel = "pubsubInputChannel")
public MessageHandler receiveMessage() {
public MessageHandler messageReceiver1() {
return message -> {
LOGGER.info("Message arrived! Payload: "
+ ((ByteString) message.getPayload()).toStringUtf8());
Expand All @@ -122,7 +118,7 @@ public MessageHandler receiveMessage() {

@Bean
@ServiceActivator(inputChannel = "pubsubInputChannel")
public MessageHandler receiveMessageInParallel() {
public MessageHandler messageReceiver2() {
return message -> {
LOGGER.info("Message also arrived here! Payload: "
+ ((ByteString) message.getPayload()).toStringUtf8());
Expand All @@ -134,17 +130,12 @@ public MessageHandler receiveMessageInParallel() {

@Bean
@ServiceActivator(inputChannel = "pubsubOutputChannel")
public MessageHandler messageSender(PubsubTemplate pubsubTemplate) throws IOException {
public MessageHandler messageSender(PubsubTemplate pubsubTemplate) {
PubsubMessageHandler outboundAdapter = new PubsubMessageHandler(pubsubTemplate);
outboundAdapter.setTopic("test");
return outboundAdapter;
}

@Bean
public MessageChannel pubsubOutputChannel() {
return new PublishSubscribeChannel();
}

@MessagingGateway(defaultRequestChannel = "pubsubOutputChannel")
public interface PubsubOutboundGateway {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#spring.cloud.gcp.projectId=[YOUR_PROJECT_ID]
#spring.cloud.gcp.credentialsLocation=file:[LOCAL_PATH_TO_CREDENTIALS]
#
#spring.cloud.gcp.pubsub.subscriber.executorThreads=[SUBSCRIBER_THREADS]
#spring.cloud.gcp.pubsub.publisher.executorThreads=[PUBLISHER_THREADS]

0 comments on commit 431123d

Please sign in to comment.