Configuring Web Logic JMS Module with Oracle AQ Queues - jndi

I testing setting up a web logic server which can use an Oracle AQ JMS implementation, but for some reason my WLS connection pool cannot see the queue I have created, the only way I can see the find the queue in web logic is to make the web logic datasource connection pool use the credentials of the DB user who created the queue.
I have done the following as admin_user:
Created a Queue Table
EXECUTE DBMS_AQADM.CREATE_QUEUE_TABLE(queue_table=>'testqueue_table',queue_payload_type=>'sys.aq$_jms_text_message');
Created a Queue
EXECUTE dbms_aqadm.create_queue(queue_name=>'testqueue', queue_table=>'testqueue_table');
Started the Queue
EXECUTE dbms_aqadm.start_queue(queue_name=>'testqueue');
Granted the CPOOL user permissions
GRANT aq_user_role TO cpool;
EXECUTE DBMS_AQADM.grant_queue_privilege(privilege=>'ALL', queue_name=>'adming_user.testqueue', grantee=>'cpool',grant_option=>FALSE);
Set up 2 JDBC DataSources in Web Logic
I set up 2 datasources in web logic which connect to my database, both are identical except that one uses the cpool user and the other uses admin_user
Create JMS Modules
Now I register a jms module with the JDBC DataSources and wire up the local and foreign JDNI names.
If I use the DataSource which uses admin_user everything works fine and my deployed application can find queue in JNDI.
Problem
If I use the data source which uses cpool then it fails finds the connection pool in JNDI but never the Queue (despite the fact it worked for admin_user). I get the following error from WL:
Related cause:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testqueue': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Cannot resolve name:Queues/TESTQUEUE
Does anyone know why WL cannot resolve the JNDI name for the queue unless I use the admin_user account for my datasource.

The answer was that my connection pool user was missing some grants, the following where required:
GRANT EXECUTE on DBMS_AQ to <CPOOL>;
GRANT EXECUTE on DBMS_AQADM to <CPOOL>;
GRANT aq_user_role to <CPOOL>;
Make sure the user who creates the destination grants access to the connection pool user:
`EXECUTE DBMS_AQADM.grant_queue_privilege(privilege=>'ALL', queue_name=>'<SCHEMAOWNER>.docprod_queue', grantee=>'<CPOOL>',grant_option=>FALSE);`
Finally in Web Logic make sure to reference the destination by their full foreign JNDI name:
Queues/<SCHEMA OWNER>.<DESTINATION_NAME>

Related

Spring Rabbit - How to recover rabbit topology for Declarables (queues/bindings/exchanges) that are not beans (when rabbit server restarts)

I use a Spring Boot application with spring-rabbit (version 2.2.2). Since the nature of my application is very dynamic, the queues and bindings are declared dynamically using RabbitAdmin.declareXXX methods, so they are not declared as Spring Beans.
From my understanding (and testing), the RabbitAdmin's functionality for auto-recovery the topology when rabbitmq server restarts is only for exchanges/queues/bindings that were declared as Spring Beans (am I correct?).
I tried to use the underlying Rabbit client's auto recovery feature using the following methods:
cachingConnectionFactory.getRabbitConnectionFactory().setAutomaticRecoveryEnabled(true)
cachingConnectionFactory.getRabbitConnectionFactory().setTopologyRecoveryEnabled(true)
However, after the rabbitmq server restart, the spring application fails with:
One org.springframework.amqp.rabbit.connection.AutoRecoverConnectionNotCurrentlyOpenException
And multiple continuous com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reploy-code=404, reply-text=NOT_FOUND - no queue 'recovery-q1' in host '/'
and nothing is getting recovered.
Note that a test without Spring, where the queue is created directly through the channel, the queue is recovered properly with its consumers.
Is there anything else I can configure to make this work?
Currently, spring only recovers Declarables that are defined as beans in the application context.
Based on your user name, I assume you opened this feature request: https://github.com/spring-projects/spring-amqp/issues/1365
Posting this here in case people come across this question.

Grails synchronize execution of service method

I am trying to add Files to a (Blog)Post Domain Object.
The file uploader allows to send multiple ajax requests one for each file in parallel.
How can I best take care of the synchronization on the server side?
To avoid:
Could not synchronize database state with session org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect):
I am doing this in Grails service with:
static scope = "session"
This didn't do what I needed.

How to prevent ADODB.Connection pooling?

I'm using Powershell v2.0, question is in the title. I'm having to use the old school ADOB.Connection (not the OLEDB provider) to open a Jet DB file (.mdb). The reason is simple, the ADODB.Connection exposes properties I need access to that the OLEDB provider doesn't.
I'm opening the DB via ADOB.Connection to query for some information, and then I'm trying to compact the DB using JRO.JetEngine. The issue is that I keep getting an error about the Jet DB being locked.
I'm explicitly calling Close on it, and setting the variable to $null, and still experiencing that issue. My best guess is that ADODB.Connection is using connection pooling, and so is not releasing the resources the way it should be.
According to http://support.microsoft.com/kb/191572, the call to close() should be enough, but it doesn't seem to be working.
Is there a way for me to explicitly specify no connection pooling when creating ADODB.Connection objects?
In the link you provided, it is said that calling to close returns the connection to the pool:
2.What statement returns the connection to the pool?
2.Conn.Close
You might need to destroy/dispose the ADODB.Connection object, so that it is removed from the pool, or, if you are using OLE DB as the provider, configure the OLEDB Services, as explained here:
Enabling OLE DB Resource.
Pooling Resource pooling can be enabled in
several ways:
For an ADO-based consumer, by keeping one open instance of a
Connection object for each unique user and using the OLEDB_SERVICES
connection string attribute to enable or disable pooling. By default,
ADO attempts to use pooling, but if you do not keep at least one
instance of a Connection object open for each user, there will not be
a persistent pool available to your application. (However, Microsoft
Transaction Server keeps pools persistent as long as the connections
in them have not been released and have not eventually timed out.)

Failure to get NHibernate session when switching to Windows Authentication

I'm trying to switch a working S#arp Architecture MVC application from an app pool with the Network Service identity to an app pool with a domain user identity. I ran aspnet_regiis on the user in the web server and gave the user permissions to access the database (even tried making it a sysadmin in the database). However, it seems like it can't get the NHibernate session.
Exception information:
Exception type: NullReferenceException
Exception message: Object reference not set to an instance of an object.
Request information:
Request URL: http://<redacted>
Request path: /<redacted>
User host address: 10.10.10.10
User: <webuser>
Is authenticated: True
Authentication Type: Forms
Thread account name: <MYDOMAIN\MYUSER>
Thread information:
Thread ID: 1
Thread account name: <MYDOMAIN\MYUSER>
Is impersonating: False
Stack trace: at SharpArch.Data.NHibernate.NHibernateSession.get_Current() in C:\MyStuff\Dev\Projects\SharpArchitecture\src\SharpArch\SharpArch.Data\NHibernate\NHibernateSession.cs:line 88
at UserAccount.Persistence.UserRepository.GetByPropertiesPartialMatching(IDictionary`2 exactMatchPropertyValuePairs, IDictionary`2 partialMatchPropertyValuePairs, MatchMode matchMode) in c:\Persistence\UserRepository.cs:line 66
...
The actual line giving the Null reference exception within SharpArch NHibernateSession.cs is:
ISession session = Storage.Session;
Clear your temp files on the server. I know it sounds crazy, but S# does file caching on the config.
I've done this several times, but have never seen the problem you are reporting. Do ANY of your calls to repositories (any of them) succeed or all but this one?
Here is what is sticking out to me. Your application spins up. If it had a connection issue, it would not be able to spin the application up. That is leading me to believe you might have another issue.
The root cause of this issue was that there was actually another exception before this one where NHibernate "couldn't compile the mapping document". The reason was that the .NET XMLSerializer needs write access to c:\windows\temp. I right-clicked this folder and added my application pool identity (a domain user) with Modify permission. It was fixed then.
This is all explained in NHibernate MappingException: Could not compile the mapping document
(So it was indeed related to temp files, Alec.)

Msmq and WCF Service

I have created a WCF service using the NetMsmq binding for which i created a private queue on my machine and executed the project. This works fine as such and my WCF service is started and accesses the message using the queue in the debugging environment. Now, I wanted to host the service using the windows service and for the same I created a new project and windows installer as well (This service runs under Local System Account). Then I tried installing this windows service using the InstallUtil command through the command prompt. When installation is happening and during the service host opening, I get an exception saying:
There was an error opening the queue. Ensure that MSMQ is installed and running, the queue exists and has proper authorization to be read from. The inner exception may contain additional information.
Inner Exception System.ServiceModel.MsmqException: An error occurred while opening the queue:Access is denied. (-1072824283, 0xc00e0025). The message cannot be sent or received from the queue. Ensure that MSMQ is installed and running. Also ensure that the queue is available to open with the required access mode and authorization.
at System.ServiceModel.Channels.MsmqQueue.OpenQueue()
at System.ServiceModel.Channels.MsmqQueue.GetHandle()
at System.ServiceModel.Channels.MsmqQueue.SupportsAccessMode(String formatName, Int32 accessType, MsmqException& msmqException)
Could anyone suggest the possible solution for the above issue? Am I missing any permissions to be set for the queue as well as the windows service, if so could you suggest where should these permissions be added?
Tom Hollander had a great three-part blog series on using MSMQ from WCF - well worth checking out!
MSMQ, WCF and IIS: Getting them to play nice (Part 1)
MSMQ, WCF and IIS: Getting them to play nice (Part 2)
MSMQ, WCF and IIS: Getting them to play nice (Part 3)
Maybe you'll find the solution to your problem mentioned somewhere!
Yes, it looks like a permissions issue.
Right click on your private queue from the Server Manager, and select Properties. Proceed to the Security tab, and make sure you have the right permissions in there for your Local System Account.
This is also confirmed in Nicholas Allen's article: Diagnosing Common Queue Errors, where the author defines the error code 0xC00E0025 as a permissions problem.
I ran into same problem, here is the solution.
Right click "My Computer" --> Manage. In Computer Management window go to "Services and Applications --> Message Queueing --> ur queue", select ur queue and access properties. Add the user running ur WCF application and give full access. This should solve the issue.
Can simple be that the service can't find the it's queue.
The queue name must exact match the endpoint address.
Example:
net.msmq://localhost/private/wf.listener_srv/service.svc
points to local queue
private$\wf.listener_srv\service.svc
If queue name and endpoint are according to each other, then is most like that the credentials defined on the IIS pool don't grant access to the queue.

Resources