I have a WebSocket app on Spring Boot. I use STOMP, and I need to get destination path when user close the tab(disconnect from WS). I intercept the disconnect either with #EventListener or extends from ChannelInterceptor and override preSend().
I tried many ways - StompHeaderAccessor.getDestination(), SessionDisconnectEvent.getMessage().getHeaders().get("simpDestination"), etc, but they all return null. Is there a working way to get the path? Maybe not using interceptors, somehow differently?
I can't speak to Spring specifics, but I don't think the information you want is available from a Stomp perspective. As noted in the Stomp 1.2 specification, the DISCONNECT frame doesn't use any kind of destination header. The only possible header is receipt. The semantics of receipts are explained here.
Related
Unfortunately Spring Integration metrics are registered when they are first used.
https://stackoverflow.com/a/63619360/13657000
this means that prometheus query functions like increase give incorrect calculations.
Is there a way to get all channel names in Spring integration so that I can initialize metrics for each channel?
I'm using dsl.
I looked at this https://gist.github.com/flopezluis/2964429 but they find their channel names using XML.
Any help is appreciated, thanks.
I'm not sure why you need names of channels since the story is really about calling a MessageChannel.send(), so you perhaps just need an ApplicationContext.getBeansOfType(MessageChannel.class). Pay attention though, that sending a message to the channel will trigger not only metrics registration but also their consumption on the other side. Therefore you might need to think about filtering these "initial" messages somehow before they reach your real consumer.
On the other hand I wonder if there is some Micrometer option to make those timer metrics to be registered eagerly even if we don't produce messages yet. Just call registry.timer() as early as possible?
I just stumbled upon the fact that there are two classes that apparently do very similar things and it is not clear to me from the documentation when to use which.
ServletBearerExchangeFilterFunction and
ServerBearerExchangeFilterFunction
both live in the same package of Spring-Boot-Security-oauth2-resource-server and serve the same purpose of transporting a bearer token from the Context into outgoing http requests.
From the names I would have guessed that the Servlet option would be used for non Reactor projects while the Server version would be used with project Reactor. However that doesn't seem to be the case. At least the Servlet version seems to be working with Spring-WebFlux.
Can anyone please explain when to use which implementation?
We apparently had a false observation when using the ServletBearerExchangeFilterFunction. I corrected this in the original Question.
It turns out the ServletBearerExchangeFilterFunction can be used to configure a WebClient for use in a WebMVC (Thread based request processing) context while the ServerBearerExchangeFilterFunction works when using SpringWebFlux.
It is possible to set client timeout via camel cxf uri options?
There is possibility to set cxf://someAddress?[options], where options can be properties.XXX.
It is possible to set somehow http client receive timeout?
I tried many of them (found in source code or via google), but no one works:
properties.com.sun.xml.ws.request.timeout
properties.com.sun.xml.internal.ws.request.timeout
properties.javax.xml.ws.client.receiveTimeout
properties.org.apache.cxf.jms.client.timeout
properties.org.apache.cxf.transport.http.async.SO_TIMEOUT
properties.conduit.client.ReceiveTimeout
properties.org.apache.cxf.transports.http.configuration.client.ReceiveTimeout
properties.http-conf:client.ReceiveTimeout
properties.HTTPClientPolicy.ReceiveTimeout
properties.org.apache.cxf.http.conduits.client.ReceiveTimeout
properties.org.apache.cxf.http.conduit.client.ReceiveTimeout
properties.org.apache.cxf.transports.http.configuration.HTTPClientPolicy.ReceiveTimeout
I know it is possible with sprinx xml, but I want it configurable via Talend context.
I also know that I can configure cxf client via CxfEndpointConfigurer bean, but camel 2.13 (upgrade is not possible) does not have configureClient method.
Thank you for answer.
As mentioned in this document you can configure HTTP Client to set timeout
<http-conf:conduit name="{http://apache.org/hello_world_soap_http}SoapPort.http-conduit">
<http-conf:client Connection="Keep-Alive"
MaxRetransmits="1"
AllowChunking="false"
ConnectionTimeout="60000"
ReceiveTimeout="60000"/>
</http-conf:conduit>
Maybe you need to use a RouteBuilder, use the java variable in your route.
Tyr do something like this:
from("cxf://someAddress?[options]?timeout=${yourTimeOutVariable}")
I am using Spring Cloud Brixton.M3 and Spring Boot 1.3.0.RELEASE. I am sort of new in this (especially in Spring Cloud). I have created Registry Server (i.e. Eureka instance), Config server and Gateway.
As per my requirement I am intercepting each request hitting the gateway in one of my Filter to extract required information from Header and based upon that I am throwing exception or forwarding / verifying that request using Feign Client. Some time hystrix throw HystrixRuntimeException when it couldn't reach out to respective services or because of any other issues.
So What I want is:
Provide default fallback method for every forwarding request, so that I can read and process it accordingly.
Global Exception handling other than #ControllerAdvice since I am not providing any custom #HystrixCommand and Controller to call services (AOP based solution ?).
Is it possible to intercept every failed request and retry them for certain number of times ? Internally it might be happening but can I override this functionality and handle each failed request either because of TimedOutException or because of HttpConnectionPool exception ?
Update
Is it a good practice to provide own routing in Zuul gateway ? using #RestController and #HystrixCommand together ? (I think its a bad idea, because over the period of time we will end up with lots of controllers and hence actual use of intelligent routing wouldn't work as expected)
Currently there is an open issue for fallbacks with feign. There is also an open issue for fallbacks with zuul.
I have traditional (com.ibm.mq.jar) MQ application in Java for testing purpose. Now I need to use that application to send some messages to JMS. When I try to set any JMS property on MQ message, for example:
message.setStringProperty("JMSDestination", "queue:///" + queueName);
I always get error: 2471 - MQRC_PROPERTY_NOT_AVAILABLE. It works if I just remove JMS from the property name.
Is it possible to set JMS properties directly on MQMessage? What is a correct way to do that on MQ level?
Btw. I have the same application in .NET where setting JMS properties this way is possible so I'm only trying to use the same code in Java.
It is not allowed to do this manually. Please use the JMS API to set JMS properties.
Restrictions to MQ properties are explained here.
One thing is interessting in that document page though,
The names of properties specified directly as MQRFH2 elements are not guaranteed to be validated by the MQPUT call.
You could perhaps work around this, on a short term basis. There seems to be no guarantee that setting the MQRFH2 elements directly will not be validated, though.