Azure Service Bus Topic InvalidSignature - spring-boot

I have a Spring Boot App with an JMSListener which consumes Messages from an Azure Service Bus Topic.
When i use the connection string of the service bus namespace everything is working fine.
But when i use the connection string of the explicit topic i get following exception:
javax.jms.JMSSecurityException: InvalidSignature: The token has an invalid signature. TrackingId:bafd2af8-a6df-4cd6-8516-c8a976f30ead_B11, SystemTracker:NoSystemTracker, Timestamp:2022-09-02T12:08:55 Reference:1d139ea9-c6dc-476d-8c56-fb3b87cde75f, TrackingId:a27aeb67-4f69-1212-b0a3-d73a84d098bd_B16, SystemTracker:my-service-bus:Topic:my-topic|sub$my-consumer$D, Timestamp:2022-09-02T12:08:55 TrackingId:5351b18caef3472db9726d30f6a14260_G7, SystemTracker:gateway5, Timestamp:2022-09-02T12:08:55 [condition = amqp:unauthorized-access]
at org.apache.qpid.jms.provider.exceptions.ProviderSecurityException.toJMSException(ProviderSecurityException.java:41) ~[qpid-jms-client-0.53.0.jar:na]
at org.apache.qpid.jms.provider.exceptions.ProviderSecurityException.toJMSException(ProviderSecurityException.java:27) ~[qpid-jms-client-0.53.0.jar:na]
The connection string looks like (copied from azure portal):
connection-string: Endpoint=sb://xxxx.servicebus.windows.net/;SharedAccessKeyName=xxxx;SharedAccessKey=xxxx;EntityPath=xxxx
I tried also some variations of the string without success.
F.e:
Endpoint=sb://xxxx.servicebus.windows.net/{topic-name}/;SharedAccessKeyName=xxxx;SharedAccessKey=xxxx;EntityPath=xxxx

Related

Feign is giving Exception code 0 instead of 503 when calling service unavailable

I am using feign client to call other microservice but when the calling service is down feign should give the exception of "503 service unavailable" but it giving exceptionCode = 0 with the message "Loadbalance does not have an available server to the client".
If the service is down, I want to hit the ErrorDecoder and retry the call, but Feign is giving 0 exception codes, so it cannot reach the error decoder.
What I am missing?
Check your service is registered with the discovery server.
Check your spring properties 'spring-application-name' is equal to feignClient annotation's value properties

Jhipster Health Endpoint fails when mailserver not connected

JHipster / Spring boot provides a nice endpoint /management/health, where it aggregates health information for subsystems like db, disk, and mail.
Unfortunately, when the connection to the mail server fails, the whole endpoint fails. So you do not get information what has failed.
I get a strack trace like this:
o.s.b.a.health.MailHealthIndicator : Health check failed
com.sun.mail.util.MailConnectException: Couldn't connect to host, port: XXXX, NNNN25025; timeout -1
...
at org.springframework.boot.actuate.health.MailHealthIndicator.doHealthCheck(MailHealthIndicator.java:40)
at org.springframework.boot.actuate.health.AbstractHealthIndicator.health(AbstractHealthIndicator.java:43)
at org.springframework.boot.actuate.health.CompositeHealthIndicator.health(CompositeHealthIndicator.java:68)
at org.springframework.boot.actuate.endpoint.HealthEndpoint.invoke(HealthEndpoint.java:85)
at org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.getCurrentHealth(HealthMvcEndpoint.java:177)
at org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.getHealth(HealthMvcEndpoint.java:166)
at org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(HealthMvcEndpoint.java:143)
This is spring boot 1.5.9
Where should I fix this, so that the exception is catched and instead a an error status is returned?
You have to turn on your SMTP server or disable checks to it.
To disable checks to SMTP server:
management.health.mail.enabled=false
To disable checks to all server:
management.health.defaults.enabled=false
for more information, see http://www.briansjavablog.com/2017/09/health-checks-metric-s-more-with-spring.html
I believe you can handle this error with the ExceptionHandler for 1.5.9 version of Spring Boot since the newer version there is no such problem:
#ControllerAdvice
public class ExceptionController {
#ExceptionHandler(MailConnectException.class)
public ResponseEntity<?> mailExceptionHandler(MailConnectException e) {
// Do your treatment ...
} ...
}

Solace NIFI JMSConnectionFactoryProvider

I am trying to connect to Solace Queues on a VPN different then default using Appache NIFI ConsumeJMS Processor. When I try to enable the JMSConnectionFactoryProvider I get the following error:
JMSConnectionFactoryProvider Failed to invoke #OnEnabled method due to
java.lang.IllegalStateException: java.lang.IllegalStateException:
Failed to load and/or instantiate class
'com.solacesystems.jms.SolConnectionFactory'
The NIFI JMSConnectionFactoryProvider provides a generic service to create vendor specific javax.jms.ConnectionFactory implementations. ConnectionFactory can be served once this service is configured successfully.
Why is NIFI Unable to find the class within the Solace JMS API Jar files?
----- Update --------
Solace JMS API 10.1.0 now contains an zero argument default constructor, and integration with NiFi is now possible.
Here is an example configuration:
Controller:
The MQ ConnectionFactory Implementation is set to com.solacesystems.jms.SolConnectionFactoryImpl.
ConsumeJMS Processor:
Username field can also take the form of "myUsername#myMessageVPN".
----- Original -------
The problem here is that Apache NiFi is not using a portable method of creating a ConnectionFactory. It is trying to create a ConnectionFactory by calling an zero argument default constructor, but there's no guarantee that one exists.
// From https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/src/main/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProvider.java
private void createConnectionFactoryInstance(ConfigurationContext context) {
String connectionFactoryImplName = context.getProperty(CONNECTION_FACTORY_IMPL).evaluateAttributeExpressions().getValue();
this.connectionFactory = Utils.newDefaultInstance(connectionFactoryImplName);
}
Note that there's an entry over at NiFi's JIRA https://issues.apache.org/jira/browse/NIFI-2701 to "Add JNDI Factory support for JMS ConnectionFactory service". (The initial description of that entry is a bit confusing, but the comments are clearer.)
At this point, Solace only supports the creation of the ConnectionFactory through the standard JNDI lookup - javax.naming.InitialContext.lookup() and through Solace's proprietary method - SolJmsUtility.createConnectionFactory().
Solace will investigate whether it is feasible to implement a zero argument default constructor for the ConnectionFactory.
A JNDI connection provider is developed and published at http://dev.solace.com/integration-guides/nifi/. For people that are interested in this provider, it is worthwhile finding out.

java.net.UnknownHostException during Eureka service discovery

According to this blog https://spring.io/blog/2015/07/14/microservices-with-spring
Was able to run the application without any issues. In this order:
java -jar microservice-demo-0.0.1-SNAPSHOT.jar registration 1111
java -jar microservice-demo-0.0.1-SNAPSHOT.jar accounts 2222
java -jar microservice-demo-0.0.1-SNAPSHOT.jar web 3333
But when trying to hit any service through the web application (http://localhost:3333/) which uses the http://ACCOUNTS-SERVICE url to access any accounts service endpoints like http://ACCOUNTS-SERVICE/accounts/123456789 I'm getting an error response:
Response Status: 500 (Internal Server Error)
Cause: org.springframework.web.client.ResourceAccessException I/O error on GET request for "http://ACCOUNTS-SERVICE/accounts/123456789": ACCOUNTS-SERVICE; nested exception is java.net.UnknownHostException: ACCOUNTS-SERVICE
When I provide the real address (http://localhost:2223/) of the accounts service to the web server instead of the http://ACCOUNTS-SERVICE everything works properly but there is no service discovery in this case.
The source code is stored at: https://github.com/paulc4/microservices-demo
This issue was due to the RestTemplate was no longer auto-created in the Brixton release-train (Spring Cloud 1.1.0.RELEASE), so the RestTemplate could not resolve properly the http://ACCOUNTS-SERVICE url using the service discovery server.
Was able to fix this issue after declaring a RestTemplate bean with #LoadBalanced as follows:
#Bean
#LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}

Unit-Of-Order in WLI JMSControl

One of our clientes is intented to use the Unit-Of-Order Weblogic Server Feature (UOO).
Everything is OK using UOO in pure java code for sending JMS Messages with custom UOO Names, as well as propagating the UOO Name in Aqualogic Service Bus from the Proxy Service to a Business Service (both using JMS as the transfer protocol).
However, using UOO in Weblogic Integration along with WLI JMSControl, does no work properly.
Consider this code:
#com.bea.control.JMSControl.Properties(value = {
#com.bea.control.JMSControl.PropertyValue(name = "JMS_BEA_UnitOfOrder", value = "MyUOONameFromWLI"),
#com.bea.control.JMSControl.PropertyValue(name = "MyCustomProperty", value = "MyCustomValue") })
public void sendTextMessage(String payload);
It sends the property MyCustomProperty to the JMS consumer, but the property JMS_BEA_UnitOfOrder - related to UOO Name - is ignored. The default User-generated UOO name is used instead.
So, how to customize my UOO Name using Weblogic JMSControl?
I've found that it has no support!

Resources