Spring Boot REST controller: can events arrive out-of-order? - fetch

If a script in a web page sends events via fetch() to a Spring Boot #RestController, one almost directly after another, is it possible that the server will receive them out-of-order?

Related

Spring Boot Kafka error messages not being logged by Datadog agent

I'm using an event handler method with #KafkaListener based on default spring-kafka library, together with the embedded Datadog agent on the container running the application.
When Rest endpoints calls fails, it automatically inject the error messages on spans and I can see them on Datadog.
Although for Kafka errors, I can only see spans with "error: true".
I'm not using anything special other than that. Is there something needed in order to track event errors on Datadog?

Spring Cloud Contract and Spring-WS Endpoints

Can Spring Cloud Contract be used to test Spring Boot services that are running Spring-WS Endpoints? I would like the ability to define SOAP requests/responses using the Groovy DSL, but I haven't been able to get these services to work with Spring Cloud Contract. I keep getting a failure (expected 200 but received a 404) when I try to run these tests. Interestingly, I added #RestController and #RequestMapping annotations to my Endpoint class (knowing it wouldn't work) just to test whether or not the fact that these services are Spring-WS endpoints and not Spring REST controllers may be the problem (i.e., does Spring Cloud Contract only "see" REST endpoints?). And...I moved on to a different set of errors. So, I am assuming at this point that I can not use Spring Cloud Contract to test my SOAP services, but I would like to know for sure (i.e., is there some way to do this that I haven't discovered yet?).
Our core services are implemented as REST services, but we still have to support our SOAP clients until they can migrate to REST, so they wrap our REST services. I need the ability to test both. I have successfully created tests for our REST services.
Try using the explicit mode to make rest assured send real request. In the base class you'll have to setup the whole application so that it bindd to a real port. Then in the before section of your test you need to tell rest assured that I'd should call the following port. And that's it :P

Spring MVC Controller Service taking too long to respond

I am working on a spring MVC application. Where I am calling my application controller methods via Ajax call.
Its taking too long to respond. (Currently I am working on my local environment)
I am doing simple operations like change some value in the model and returning back the view.
(No database involved) in those.
Also I am using apache tiles to configure my views.
Any idea what is going wrong?

How to integrate spring-integration in an existing spring-mvc application?

i have a typical spring-webmvc application (with REST request mapped in Controller's method that call a Service's method) and I would like to use spring-integration to manage the asynchronous functionality (e.g. mail, sms, notification...).
For example i would like that a Service Component after insert in my DB publish a message in spring-integration context channel in asycn mode so that the control return immediataly at the Controller to return an http response to the client.
How to integrate "spring-integration" in my existing spring-mvc application?
Simply inject a Messaging Gateway into your controller. Define an interface, declare an <int:gateway id="toMail"/> and use normal Spring bean injection techniques to inject the gateway (as an instance of your interface) into the controller.
If you don't want to wait for a a reply; set the method return value to void and, if you make the first channel (the gateway's default-request-channel) an Executor Channel, the message will be handed off to another thread and the gateway will returm immediately.
Configuring an Executor Channel.

Invoking Spring MVC controller method from another thread (javax.jms.MessageListener)

I'm looking for a way of sending messages to my Spring MVC Controller from another thread. In particular my thread is an implementation of javax.jms.MessageListener which listens for messages on a ActiveMQ queue. As soon as I get a new message in the Queue, the jms MessageListener's onMessage() method is invoked. However, now I want to invoke another method in my spring controller whenever MessageListener's onMessage() is invoked.
The controllers in Spring MVC are not intended to be directly invoked the way you are looking for, but are designed to handle and respond to to web requests. A cleaner way to handle what you are doing will be to move the controller logic that you plan to invoke to a services layer and invoke this common services layer from controller and JMS listener.
If you absolutely want to, you can always autowire in a controller and invoke methods on it as if it is a normal POJO though.

Resources