Spring jms listener configuration - Websphere MQ resource adapter 7.5 - JBoss EAP 6.2 - jboss7.x

I'm looking for some help.
Context:
Application configuration,
JBoss EAP 6.2,
WebSphere MQ 7.5 Resource Adapter,
Spring
Current Status:
Application manages to send messages just fine, but unless we "boost" the number of connections related to message consumption, we have a warning message popping up in the logs:
WARN [org.springframework.jms.listener.DefaultMessageListenerContainer] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-28) Setup of JMS message listener invoker failed for destination 'jms/workflowInputQueue' - trying to recover. Cause: MQJCA1018: Only one session per connection is allowed.
Research result:
After some research, I identified the root cause from the following 2 links,
and is referenced here Removal of internal Connection Pooling for WebSphere MQ Classes
and here IBM MQ - Configuring the resource adapter for inbound communication
The root cause of the issue can be summarized by this quote:
For Inbound Communications, the JMS Connection Pools and JMS Session Pools are implemented by the WebSphere MQ JCA resource adapter.
What I'm looking for:
I don't have prior Spring knowledge, my tasks usually were focused on Linux/Unix Administration, Application Server setup and configuration.
I'd like:
A sample configuration for a jms listener (MDP), with some indication of what can be configured in JBoss, and what cannot and should be configured in spring or other xml configuration (Activation Spec being an example
Additional sources I can read to better understand the spring configuration
Some explanation on how to reference the resource adapter in the Spring configuration, while the wmq.jmsra.rar resource adapter has been uploaded in the JBoss Content Repository, and assigned to the same server group as the application.
The ideal form of the solution:
A sample Spring configuration (xml based), with Resource adapter, ActivationSpec, MessageEndpointListener or (jca-?)listener-container, that would provide a good overview of the configuration necessary
Possibly explanations on how to define all this configuration in JBos, and make reference to it in spring through jndi lookup.
I already asked this question through the JBoss Community forum but haven't received much feedback
Current problematic configuration:
/profile=myapp/subsystem=resource-adapters/resource-adapter=wmq.jmsra.rar/connection-definitions=myappListenerQCF:read-resource(include-defaults=true,recursive=true)
{
"outcome" => "success",
"result" => {
"allocation-retry" => undefined,
"allocation-retry-wait-millis" => undefined,
"background-validation" => false,
"background-validation-millis" => undefined,
"blocking-timeout-wait-millis" => undefined,
"class-name" => "com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl",
"enabled" => true,
"flush-strategy" => "FailingConnectionOnly",
"idle-timeout-minutes" => undefined,
"interleaving" => false,
"jndi-name" => "java:/jms/myappListenerQCF",
"max-pool-size" => "100",
"min-pool-size" => "100",
"no-recovery" => false,
"no-tx-separate-pool" => false,
"pad-xid" => false,
"pool-prefill" => "true",
"pool-use-strict-min" => "true",
"recovery-password" => undefined,
"recovery-plugin-class-name" => undefined,
"recovery-plugin-properties" => undefined,
"recovery-security-domain" => "wsmq_security",
"recovery-username" => undefined,
"same-rm-override" => undefined,
"security-application" => false,
"security-domain" => "wsmq_security",
"security-domain-and-application" => undefined,
"use-ccm" => true,
"use-fast-fail" => false,
"use-java-context" => true,
"use-try-lock" => undefined,
"wrap-xa-resource" => true,
"xa-resource-timeout" => undefined,
"config-properties" => {
"hostName" => {"value" => "mqserverhostname"},
"port" => {"value" => "1520"},
"channel" => {"value" => "channelname"},
"transportType" => {"value" => "CLIENT"},
"queueManager" => {"value" => "qmname"}
}
}
}
/profile=myapp/subsystem=resource-adapters/resource-adapter=wmq.jmsra.rar/admin-objects=workflowInputQueue:read-resource(include-defaults=true,recursive=true)
{
"outcome" => "success",
"result" => {
"class-name" => "com.ibm.mq.connector.outbound.MQQueueProxy",
"enabled" => true,
"jndi-name" => "java:/jms/workflowInputQueue",
"use-java-context" => true,
"config-properties" => {"baseQueueName" => {"value" => "QUEUE.IN"}}
}
}
Also worth noting that there is another post on Stack Overflow entitled "Spring JMS and WebSphere MQ", which covers at least partly the subject, but not at all the jboss aspect.
I'd favor being able to push most of the configuration at jboss level and just look it up in Spring if possible.
Thanks in advance for all the input the community could provide

Related

Unable to run migrations on GCP with CakePHP 3.8

I am trying to set up my CakePHP 3.8 project on a GCP "Compute Engine" VM.
I have set up my app.php to use the following DB configuration:
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'username' => 'user',
'password' => 'password',
'database' => 'dbname',
'prefix' => '',
'encoding' => 'utf8',
'timezone' => 'UTC',
'cacheMetadata' => true,
'log' => false,
'flags' => [
PDO::MYSQL_ATTR_INIT_COMMAND => "SET ##SESSION.sql_mode='';",
// uncomment below for use with Google Cloud SQL
PDO::MYSQL_ATTR_SSL_KEY => CONFIG.'ssl/client-key.pem',
PDO::MYSQL_ATTR_SSL_CERT => CONFIG.'ssl/client-cert.pem',
PDO::MYSQL_ATTR_SSL_CA => CONFIG.'ssl/server-ca.pem',
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false
],
'cacheMetadata' => true,
'log' => false,
My problem happens when I try to run migrations. The site works just fine with the above configuration, however, if I run
$> php bin/cake.php migrations migrate
I get a slew of errors saying that it cannot connect, access denied for user#host.
If I add
'ssl_key' => CONFIG .'ssl/client-key.pem',
'ssl_cert' => CONFIG . 'ssl/client-cert.pem',
'ssl_ca' => CONFIG . 'ssl/server-ca.pem',
I get an error:
Caused by: [PDOException] PDO::__construct(): Peer certificate CN=`gcpname:gcpserver' did not match expected CN=`111.111.111.111' in /var/www/mydomain.com/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php on line 79
I guess this is because the migrations plugin still doesn't pass the flags or custom mysql_attr_* options over to the Phinx connection configuration, see this issue:
https://github.com/cakephp/migrations/issues/374
I don't think there's much that can be done here, other than adding support for flags / attribute options, or using Phinx directly (ie without the Migrations plugin).
I've pushed a PR that would add support for driver specific flags, you might want to give it a try and comment on the issue or the PR whether it works for you (it's for CakePHP 4.x (Migrations 3.x), I'll backport it for CakePHP 3.x (Migrations 2.x) in case it's being accepted):
https://github.com/cakephp/migrations/pull/478

How can I use 'puppetlabs/rabbitmq' module to set up HA rabbitMQ?

I am in no ways an expert on RabbitMQ, but I am trying to puppetize the setup of a RabbitMQ cluster. In the documentation a co-worker of mine wrote I need to implement the equivalent of executing ...
rabbitmqctl set_policy HA '^(?!amq.).*' '{"ha-mode": "all"}
... in my puppet manifest. I tried this ...
rabbitmq_policy { 'HA':
pattern => '^(?!amq.).*',
priority => 0,
applyto => 'all',
definition => {
'ha-mode' => 'all',
'ha-sync-mode' => 'automatic',
},
}
... but I get this error when I do my "puppet agent -t" on my rabbit code:
Error: Failed to apply catalog: Parameter name failed on Rabbitmq_policy[HA]: Invalid value "HA". Valid values match /^\S+#\S+$/. at /etc/puppetlabs/code/environments/production/modules/core/wraprabbitmq/manifests/init.pp:59
What am I doing wrong? Also do I have/need to have something like this ...
rabbitmq_vhost { 'myvhost':
ensure => present,
}
... if I am setting up HA rabbitMQ?
Update: Thanks Matt.
I am using this now:
rabbitmq_policy { 'HA#/':
pattern => '^(?!amq.).*',
priority => 0,
applyto => 'all',
definition => {
'ha-mode' => 'all',
'ha-sync-mode' => 'automatic',
},
}
Also I did not need to use this:
rabbitmq_vhost { 'myvhost':
ensure => present,
}
Checking the source code here: https://github.com/puppetlabs/puppetlabs-rabbitmq/blob/master/lib/puppet/type/rabbitmq_policy.rb#L21-L24
we see that the name parameter for that type needs to be 'combination of policy#vhost to create policy for.' Your value of 'HA' does not follow that nomenclature and thus fails the regexp check of /^\S+#\S+$/.
You need to put a name following the format of 'policy#vhost' for the rabbitmq_policy resource and then your code will compile.

How do I configure rabbitmq queue via puppet

I'm trying to install rabbitmq via puppet. I'm using the puppetlabs-rabbitmq module. It also has section to configure queues and exchanges, which are Native Types. I can't figure out how to use these native types.
My code for rabbitmq installation:
class rabbitmq-concrete{
$tools = ["vim-enhanced","mc"]
package { $tools: ensure => "installed" }
$interface = "enp0s8"
$address = inline_template("<%= scope.lookupvar('::ipaddress_${interface}') -%>")
class { 'rabbitmq':
config_cluster => true,
cluster_nodes => ['rml01', 'rml02'],
cluster_node_type => 'disc',
manage_repos => true,
node_ip_address => $address,
erlang_cookie => 'rmq_secret',
}
rabbitmq_exchange { "logging#${node_name}":
type => 'topic',
ensure => present,
}
rabbitmq_queue { "logging#${node_name}":
durable => true,
auto_delete => false,
arguments => {
x-message-ttl => 123,
x-dead-letter-exchange => 'other'
},
ensure => present,
}
rabbitmq_binding { "logging#logging#${node_name}":
destination_type => 'logging',
routing_key => '#',
arguments => {},
ensure => present,
}
}
include rabbitmq-concrete
I get following error:
==> rml01: Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type rabbitmq_queue at /tmp/vagrant-puppet-2/manifests/site.pp:35 on node rml01
==> rml01: Wrapped exception:
==> rml01: Invalid resource type rabbitmq_queue
==> rml01: Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type rabbitmq_queue at /tmp/vagrant-puppet-2/manifests/site.pp:35 on node rml01
Note: When I leave out these native types, rabbit installation works well.
How do I use Native Types to configure rabbitmq_queue, rabbitmq_exchange and rabbitmq_binding ?
Do you have the required prerequisites? You need the following packages from the Forge:
puppetlabs/stdlib
stahnma/epel
nanliu/staging
garethr/erlang
To your manifest I added:
include epel
include staging
class { 'erlang': epel_enable => true}
Your question is dated 13th Feb, yet looking on the Puppet Forge those features were only added to that module in the most recent release on 10th March in version 5.1.0.
Full changelog => https://forge.puppetlabs.com/puppetlabs/rabbitmq/changelog
Abridged:
"2015-03-10 - Version 5.1.0
Summary
This release adds several features for greater flexibility in configuration of rabbitmq, includes a number of bug fixes, and bumps the minimum required version of puppetlabs-stdlib to 3.0.0.
Features
Add rabbitmq_queue and rabbitmq_binding types"

activeMQ with logstash

can activeMQ work with logstash?
I was switching from rabbitMQ to activeMQ, and trying to make logstash to work with activeMQ..
In my previous rabbitMQ, I have something like:
input {
rabbitmq {
host => "hostname"
queue => "queue1"
key => "key1"
exchange => "ex1"
type => "all"
durable => true
auto_delete => false
exclusive => false
format => "json_event"
debug => false
}
}
filter {....}
on logstash webpage -> doc, it does not show activeMQ supported as input...
http://logstash.net/docs/1.4.1/
any suggestions?
You can probably use (not tried it myself) the STOMP input. ActiveMQ supports stomp.

How to set redis connection timeout?

Where in the configuration file do I set the connection timeout for Redis?
I know there is a timeout setting in the config file, but that only applies for idle connections. I want the timeout to apply when I want to read from redis. I want it to time out only after N seconds, rather than the default.
For anyone who is still looking for this, on a redis connnection string you can specify connectTimeout like below.
<add key="RedisConnectionString" value="your-redis-server,abortConnect=false,connectTimeout=1000,ssl=false,,password=your-password" />
On console of redis set this configuration
config set timeout 300
You basically need a read-timeout
This will be a client side property
Mention this in your application.
I'll examplify for Laravel framework of PHP
specify it at database.php file ('read_timeout' => 60)
'redis' => [
'client' => 'predis',
'cluster' => false,
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
'read_timeout' => 60,
],
],
];