These are chat archives for spring-cloud/spring-cloud

28th
Mar 2018
Maroua DRISSI
@marouaDrissi
Mar 28 2018 11:46
@ryanjbaxter thanks for replying me , my projet architecture is based on micro services I am using spring boot 2.0 because one of the imposed requirements is to use reactive programming (the main goal is to have a full reactive micro services through using spring web flux, reactive spring data (redis/cassandra/mongo/couchbase) + angular5(using RxJs), so my problem is when I add the dependencies (spring-cloud-starter-netflix-hystrix / spring-cloud-starter-netflix-hystrix-dashboard / spring-boot-starter-actuator) plus the annotations ( @EnableHystrixDashboard and @EnableCircuitBreaker) and some fallbackmethods , after I run my projects and I test some services I open http://localhost:port_number/hystrix and I enter the url(http://localhost:port_number/hystrix.stream and I enter the name of the project which I would like to see its metrics) I get this message in red "Unable to connect to Command Metric Stream" when I open the brower console I get this message " EventSource's response has a MIME type ("text/plain") that is not "text/event-stream". Aborting the connection." I tried o many trics but none of them worked, but when I add this bean ( @Bean
public ServletRegistrationBean servletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(new HystrixMetricsStreamServlet(), "/hystrix.stream");
return registration;
}
) I got the metrics and the hystrix dashboard displays the metrics normally ... I want to understand why do I have to add this bean in order to the hystrix stream to wrok and the metrics to be shown ? Is is an issue or maybe I am missing something ?
I'm not sure there is a reactive version of that endpoint though.
The fact that you said it works with the servlet makes me think you are not using the reactive web stack
So you probably just need to use the right path
Maroua DRISSI
@marouaDrissi
Mar 28 2018 12:29
@dsyer yes you're absolutely right I added
management.server.servlet.context-path=/actuator
management.endpoints.web.base-path=/ ( as it is commented in the HystrixWEbFluxCommand class "path needs to be empty, so it registers correct as /actuator/hystrix.stream" ) and it worked
thanks a lot
Maroua DRISSI
@marouaDrissi
Mar 28 2018 16:15
@dsyer in the migration-guide it is said that "All endpoints have moved to /actuator by default" so why do I have to adjust the path ? I'm just trying to understand once and for all
Dave Syer
@dsyer
Mar 28 2018 16:37
The default location of the endpoints changed. So if you upgrade you have to expect that. What's hard to understand about it?
Maroua DRISSI
@marouaDrissi
Mar 28 2018 17:15
no not at all ! I was just trying to understand the migration process, sorry for bothering you and thanks again :smile:
ulmermark
@ulmermark
Mar 28 2018 18:54
if using a config server backed by a database, what should the "profile" column be set to for "global" properties to be used in all profiles? NULL or default?
Josiah Haswell
@josiahhaswell
Mar 28 2018 23:09
I'm having troubles getting @SqsListener annotations to work
I can send and receive messages via SQS just fine using the templates
But for whatever reason, the annotated methods just aren't being called


    @Bean
    public MessageReceiver messageReceiver() {
        return new MessageReceiver();
    }

    @Bean
    public SimpleMessageListenerContainerFactory simpleMessageListenerContainerFactory(AmazonSQSAsync sqsClient) {
        SimpleMessageListenerContainerFactory factory = new SimpleMessageListenerContainerFactory();
        factory.setAmazonSqs(sqsClient);

        return factory;
    }

    @Bean
    public QueueMessageHandlerFactory queueMessageHandlerFactory(AmazonSQSAsync sqsClient) {
        QueueMessageHandlerFactory factory = new QueueMessageHandlerFactory();
        factory.setAmazonSqs(sqsClient);
        return factory;
    }

    @Bean
    public QueueMessagingTemplate queueMessagingTemplate(AmazonSQSAsync client) {
        return new QueueMessagingTemplate(client);
    }

    @Bean
    public SimpleMessageListenerContainer simpleMessageListenerContainer() {
        SimpleMessageListenerContainer msgListenerContainer = simpleMessageListenerContainerFactory().createSimpleMessageListenerContainer();
        msgListenerContainer.setMessageHandler(queueMessageHandler());

        return msgListenerContainer;
    }

    @Bean
    public SimpleMessageListenerContainerFactory simpleMessageListenerContainerFactory() {
        SimpleMessageListenerContainerFactory msgListenerContainerFactory = new SimpleMessageListenerContainerFactory();
        msgListenerContainerFactory.setAmazonSqs(amazonSQS());
//        msgListenerContainerFactory.setDeleteMessageOnException(false);
        msgListenerContainerFactory.setMaxNumberOfMessages(10);
        msgListenerContainerFactory.setWaitTimeOut(10000);

        return msgListenerContainerFactory;
    }


    @Bean
    public QueueMessageHandler queueMessageHandler() {
        QueueMessageHandlerFactory queueMsgHandlerFactory = new QueueMessageHandlerFactory();
        queueMsgHandlerFactory.setAmazonSqs(amazonSQS());

        QueueMessageHandler queueMessageHandler = queueMsgHandlerFactory.createQueueMessageHandler();


        return queueMessageHandler;
    }

    @Bean
    @Primary
    public AmazonSQSAsync amazonSQS() {
        return AmazonSQSAsyncClient.asyncBuilder()
                .withCredentials(
                        new AWSStaticCredentialsProvider(
                                new BasicAWSCredentials(
                      //stuff

                                ))).withRegion(Regions.DEFAULT_REGION)
                .build();
    }
And then, the annotation-driven bean:
@Component
public class MessageReceiver {

    @MessageMapping("frapper")
    @SqsListener("frapper")
    public void receiveThing1(@NotificationMessage  ThingOne one, @Header("SenderId") String senderId) {
        System.out.println("Got a thing one");
    }

    @SqsListener("thing2")
    public void receiveThing2(ThingTwo one, @Header("SenderId") String senderId) {
        System.out.println("Got a thing 2");
    }
}
Josiah Haswell
@josiahhaswell
Mar 28 2018 23:49
Eh, I've tried it with just the @EnableSqs too. If there's a trick in the docs, it's not obvious