Using spring-rabbit, spring-amqp. How to collect rabbitMQ metrics inside client machine - spring-amqp

On client machine, I am using spring-rabbit-1.6.7.RELEASE.jar and spring-amqp-1.6.7.RELEASE.jar to perform operations on RabbitMQ.
Now, need is to monitor the metrics like # of open channels, # of rejected messages etc from given client machine to RabbitMQ server.
www.rabbitmq.com/monitoring.html mentions that some client libraries and frameworks provide means of registering metrics collectors or collect metrics out of the box. RabbitMQ Java client and Spring AMQP are two examples.
Please suggest how I can use Spring AMQP to collect metrics with respect to given client machine to RabbitMQ server.
Please note I am using org.springframework.amqp.rabbit.connection.CachingConnectionFactory. But it doesn't have any method to set metric collector..
We are using xml with following tags to define connection factory, queue, binding etc.
Rabbit:Queues , Rabbit:queue-arguments , • Rabbit:DIRECTExchange , Rabbit:TOPICExchange, Rabbit:binding , Rabbit:Admin [[[ ConnectionFactory]]]
e.g.
<bean id="connectionFactory"
class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
<constructor-arg value="#{messagingProperties['mq.hostname']}" />
<property name="virtualHost" value="#{messagingProperties['mq.virtual-host']}" />
<property name="username" value="#{messagingProperties['mq.username']}" />
<property name="password" value="#{messagingProperties['mq.password']}" />
<property name="channelCacheSize" value="25" />
</bean>

1.6.7 is extremely old; you should upgrade to at least 1.7.14; the current version is 2.1.8.
You can set the metricsCollector on the underlying rabbit connection factory.
connectionFactory.getRabbitConnectionFactory().setMetricsCollector(...);
Or use the RabbitConnectionFactoryBean to create the underlying connection factory, and then inject it into the CachingConnectionFactory.
<bean id="rcf" class= "...RabbitConnectionFactoryBean">
... set all the properties here
</bean>
<bean id="connectionFactory"
class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
<constructor-arg ref="rcf" />
<property name="channelCacheSize" value="25" />
</bean>

Related

SAML assertion fails

I have a Spring-SAML app with Okta as IDP. I'm doing IDP initiated flow and
get this exception :
org.opensaml.common.SAMLException: Endpoint with message binding urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST and URL https://<myCompanyUrl>.com/saml/SSO wasn't found in local metadata
When I look at my local metadata I see:
<md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
Location="https://<server IP address> :<server port>/saml/SSO" index="0" isDefault="true"/>
Looks like it is trying to match a URL containing a hostname to a URL with a server IP address. The location field is auto-generated. Does anybody know what configuration option affects this?
UPDATE 1
here is my metadataGeneratorFilter config :
<bean id="metadataGeneratorFilter" class="org.springframework.security.saml.metadata.MetadataGeneratorFilter">
<constructor-arg>
<bean class="org.springframework.security.saml.metadata.MetadataGenerator">
<property name="entityId" value="https://myHostname/myApp"/>
</bean>
</constructor-arg>
</bean>
All right mystery solved:
Per Spring-SAML documentation , when you are in a reverse-proxy / load balancer set up you have to make sure to specify
<property name="entityBaseURL" value="https://www.myserver.com/spring-security-saml2-sample"/>
See SPRING-SAML documentation
10.1 Reverse proxies and load balancers

Is Jasypt secure enough to use?

We are using Jasypt in one of our Spring based project to encrypt our database properties. As per Jasypt documentation we need to make algorith and password (secret) entry in our application context.
<bean id="environmentVariablesConfiguration"
class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">
<property name="algorithm" value="PBEWithMD5AndDES" />
<property name="passwordEnvName" value="secret" />
</bean>
<bean id="configurationEncryptor"
class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
<property name="config" ref="environmentVariablesConfiguration" />
</bean>
<bean id="propertyConfigurer"
class="org.jasypt.spring.properties.EncryptablePropertyPlaceholderConfigurer">
<constructor-arg ref="configurationEncryptor" />
<property name="location" value="classpath*:*.properties" />
</bean>
If we do that, any one can easily decrypt our properties by decrypt property provided by Jasypt only. For example
sh decrypt.sh input=pYmd0m1m2nEAGIeTtfdfdfdl/e3W49e password=sdsdfsf algorithm=PBEWithMD5AndDES
So how we can ensure the security of our property files.

No reply received - perhaps a timeout in the template?

I have done following RabbitMQ-Spring configuration for RPC call
Following is the configuration:-
/>
<rabbit:queue name="identity.queue" />
<rabbit:direct-exchange name="identity.exchange">
<rabbit:bindings>
<rabbit:binding queue="identity.queue" key="identity.binding"/>
</rabbit:bindings>
</rabbit:direct-exchange>
<bean id="idenityListener"
class="org.springframework.amqp.remoting.service.AmqpInvokerServiceExporter">
<property name="serviceInterface" value="<<package>.AA" />
<property name="service" ref="AAProxy" />
<property name="amqpTemplate" ref="template" />
</bean>
<rabbit:listener-container connection-factory="connectionFactory">
<rabbit:listener ref="idenityListener" queue-names="identity.queue" />
</rabbit:listener-container>
At client side:-
/>
<bean id="identityClient"
class="org.springframework.amqp.remoting.client.AmqpProxyFactoryBean">
<property name="amqpTemplate" ref="identityTemplate" />
<property name="serviceInterface" value="<<package>.AA" />
</bean>
<bean id="AAProxy" class="<xx>.AAProxy" init-method="init" />
<rabbit:template id="identityTemplate" connection-factory="connectionFactory" reply-timeout="2000"
routing-key="identity.binding" exchange="identity.exchange" />
I am getting the following error while setup for RabbitMQ RPC call. This setup working on same machine and while not working on different machine:-
Caused by: org.springframework.remoting.RemoteProxyFailureException: No reply received - perhaps a timeout in the template?
at org.springframework.amqp.remoting.client.AmqpClientInterceptor.invoke(AmqpClientInterceptor.java:60)
**Log file:-**
=ERROR REPORT==== 19-Feb-2015::10:05:59 ===
Channel error on connection <0.1474.0> (172.16.206.139:59826 -> 172.16.206.154:5672, vhost: '/', user: 'reetesh'), channel 13:
{amqp_error,not_found,"no queue 'identity.queue' in vhost '/'",
'queue.declare'}
Whenever I tried to connect I found following above in log.
Reetesh
i had a similar problem, i not fix them. Finally i use "direct reply-to"
See
http://docs.spring.io/spring-amqp/docs/1.4.3.BUILD-SNAPSHOT/reference/html/amqp.html
3.7.1 section.
with this configuration not needs a fixed reply queue and "reply-listener" is not required and should not be configured.

can I define the activemq admin console url?

Activemq's admin console, as standard, points to 0.0.0.0:8161.
I know I can change the port from 8161 in the jetty.xml config file.
Is it possible to change the URL from 0.0.0.0?
The answer was pretty obvious. In jetty.xml:
<bean id="Connector" class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<property name="port" value="8161" />
<property name="host" value="HOSTNAME" />
</bean>

JMX server locator replacement in JBoss AS 7 for class MBeanServerLocator

I am currently using JBoss 4.3 for a web application. I would like to move to the JBoss AS 7. I have been able to fix must of the differences of the application in both versions but one. The application has some JMX beans that are created thru the spring framework. Unfortunately the AS 7 release removed the class: org.jboss.mx.util.MBeanServerLocator which was used in spring to locate the JBoss JMX server and create some beans. I am not to familiar with JMX but so far the only thing I have found so far is:
"http://lists.jboss.org/pipermail/jboss-as7-dev/2011-February/000569.html". I was wondering if somebody knows how to replace the class above from JBOSS with the new JMX 1.6 classes. Here is my spring configuration snipet for the piece I need to fix:
<bean class="org.springframework.jmx.export.MBeanExporter">
<property name="server">
<bean class="org.jboss.mx.util.MBeanServerLocator" factory-method="locateJBoss"/>
</property>
<property name="beans">
<map>
<entry key="MywebMbeans:name=profileListenerContainer" value-ref="profileListenerContainer"/>
<entry key="MywebMbeans:name=jmsSenderService" value-ref="jmsSenderService"/>
<entry key="MywebMbeans:name=mailSender" value-ref="mailSender"/>
</map>
</property>
<property name="assembler" ref="mbeanAssembler"/>
</bean>
Thanks,
The MBeanServer used by JBoss 7 (by default) is the platform MBeanServer. The class name is com.sun.jmx.mbeanserver.JmxMBeanServer and the default domain is DefaultDomain. Accordingly, you can simply use:
java.lang.management.ManagementFactory.getPlatformMBeanServer()
Alternatively:
for(MBeanServer server: javax.management.MBeanServerFactory.findMBeanServer(null)) {
if("DefaultDomain".equals(server.getDefaultDomain())) return server;
}
throw new Exception("Failed to locate MBeanServer");
Actually I just look in the JMX page for spring
http://static.springsource.org/spring/docs/1.2.x/reference/jmx.html
The following will work in both JBoss instaces 4 and 7.
<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean">
<property name="locateExistingServerIfPossible" value="true" />
</bean>
<bean class="org.springframework.jmx.export.MBeanExporter">
<property name="server" ref="mbeanServer"/>
</property>
<property name="beans">
<map>
<entry key="MywebMbeans:name=profileListenerContainer" value-ref="profileListenerContainer"/>
<entry key="MywebMbeans:name=jmsSenderService" value-ref="jmsSenderService"/>
<entry key="MywebMbeans:name=mailSender" value-ref="mailSender"/>
</map>
</property>
<property name="assembler" ref="mbeanAssembler"/>
</bean>

Resources