MDB and Singleton
I have a MDB that receives data from a JSM queue in XML format. After converting the XML to proper Value Objects using JAXB, it calls a DAO.
We have configure the App server (WLS 8.1)to have 10 MDB in the pool.
The DAO is a singleton with a none static private data member that holds the DataSource.
The DAO.add() operation gets connection from the data source and performs the add.
When we put one msg on the JMS queue we see the transaction time in DAO.add() is an about 1 sec.
When we put 30 msgs on the JMS queue we see 10 threads accessing the singleton instance of the DAO.
I was hoping to see the DB transactions started by these 10 threads would be executed in parallel they way threaded operations should behave considering the context switching factor however what I am seeing from the log files is that the DB transactions are serialized meaning they get executed one at a time!!?? Therefore it takes 10 sec for the 10 threads to complete their work. I was expecting to see something like 3 to 4 sec for all 10 thread to complete the add operation.
Anyone has any ideas? Could it be that the Datasource is a private member of the Singleton DAO and each thread who calls the DAO.add() gets queued up to get access to the Data Source?
Any idea would be great.
Thanks.
Thanks for your answer,
So you never load classes then from configuration file? For example lets say you are processing xml message and for each xml message tag name you have in configuration file the appropriate class to handle such a message. Instead of configuration files would you then just store the values in a map of messageTagName to JNDI name?
Thanks
http://www.ellasweddingfavors.com
Message was edited by:
fkzeljo
Ellas Wedding Favors
Similar Messages
-
EJB 3.0 MDB and transactions
I'm trying to use an XA topic connection factory in my MDB, I was getting a "not supported in this release" error until I added this annotation to my MDB:
@MessageDrivenDeployment(
resourceAdapter = "myProviderInstance"
But now my MDB is no longer dequeuing messages.
I found the following in the docs (http://download-west.oracle.com/docs/cd/B31017_01/web.1013/b28221/undejdev010.htm#CCHGGHAE)
--- BEGIN QUOTE FROM ORACLE DOCS ---
If you use @MessageDrivenDeployment, you can configure message service options using nested @ActivationConfigProperty annotations or using @MessageDrivenDeployment attributes: @ActivationConfigProperty configuration overrides @MessageDrivenDeployment attributes.
If you use @MessageDriven, you can configure message service options using nested @ActivationConfigProperty annotations only.
If you configure using @MessageDrivenDeployment attributes, your application can only access a message service provider without a J2CA resource adapter. If later you decide to access your message service provider using a J2CA resource adapter, your application will fail to deploy. If you configure using nested @ActivationConfigProperty annotations, your application can access a message service provider with or without a J2CA resource adapter. Oracle recommends that if you configure using annotations, you should use the @ActivationConfigProperty approach.
Example 2-6 shows both a @MessageDrivenDeployment and @MessageDriven annotation using @ActivationConfigProperty annotations for message service configuration. Note that the DestinationName activation configuration property in the @MessageDrivenDeployment annotation overrides that in the @MessageDriven annotation.
Example 2-6 @MessageDriven and @MessageDrivenDeployment Annotation for a J2CA Message Service Provider
import javax.ejb.MessageDriven;
import oracle.j2ee.ejb.MessageDrivenDeployment;
import javax.ejb.ActivationConfigProperty;
import javax.jms.Message;
import javax.jms.MessageListener;
@MessageDriven(
activationConfig = {
@ActivationConfigProperty(
propertyName="DestinationName", propertyValue="OracleASjms/MyQueue"
@MessageDrivenDeployment(
activationConfig = {
@ActivationConfigProperty(
propertyName="DestinationName", propertyValue="OracleASjms/DeployedQueue"
@ActivationConfigProperty(
propertyName="ResourceAdapter", propertyValue="OracleASjms"
--- END QUOTE FROM ORACLE DOCS ---
So, instead of specifying the resource adapter as I had above, I simply pasted the last bit of annotations from the docs into my MDB, and much to my surprise I learned that you can't have an activationConfig in a @MessageDrivenDeployment
What's the solution?OK, I got a little further. Everything works now as such
I'm using the XA topic connection factory, I'm using the resource adapter.
BUT, when I set the transaction required attribute on the MDB, I no longer receive messages.
No errors are logged anywhere. Any suggestions? -
Java reflection and singletons
Using java reflection and singletons .. anyone seen this being used?
I've solved it
I had a singleton but then it turned out i had to use reflection instead, i tried to used reflection on 3 methods but the session value within was null upon the second method call. Relfection was re-creating the Object.
Sorry for wasting your time. -
MDB and JMS on different servers
Hi,
My MDB is deployed on a different domain from the JMS server. Both are on weblogic.
While deploying weblogic, I m getting an error: Unable to create a connection.
Can anyone give pointers?
I have ensured the following:
1. The JMS server starts before the MDB server
2. The following data is mentioned in weblogic-ejb-jar.xml:
jndi name of the remote queue
provider url--- t3://hostName:port
jndi name of the remote connection factory
is there anyting else that i m missing ?
thanx and regards
Shivraman GiriHi,
Thanx for responding.
I will keep in mind these points when I use a foreign JMS provider. T
Right now I m getting problem when the JMS provider is remote but native ie. MDB and JMS are both on Weblogic. This obviates the need to mention Initial Context. Only the provider URL is to be specified.
Can you suggest a reason as to why i my EJB container (first weblogic ) is unable to connect to JMS provider (another weblogic)
regards
S.G -
Creating a MDB and Distributed Queue in Clustered env in weblogic 9.2
I have created 3 managed servers and all these managed servers are in the cluster.
Now i create JMS module for this cluster and create the Connection factory 'QUEUE_CF_8' and distributed Queue 'DIS_QUEUE_8' targeting to the cluster.
I create a MDB and JMS client and deploy them in the cluster.JMS client sends the message to the distributed queue and MDB is listening to the distributed queue
When i deploy the MDB , it is deploys perfectly . But when i run the client it fails with the following exception
[java] javax.naming.NameNotFoundException: Unable to resolve 'QUEUE_CF_8'. Resolved '' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'QUEUE_CF_8'. Resolved '']; remaining name 'QUEUE_CF_8'
When i view the JNDI tree for all the managed servers , i can see the Connection factory and the distributed queue.
Also i deploy the MDB to the cluster and no submoduletargets are specified.
Let me know what is that iam missing.<?xml version='1.0' encoding='UTF-8'?>
<weblogic-jms xmlns="http://www.bea.com/ns/weblogic/90" xmlns:sec="http://www.bea.com/ns/weblogic/90/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wls="http://www.bea.com/ns/weblogic/90/security/wls" xsi:schemaLocation="http://www.bea.com/ns/weblogic/920 http://www.bea.com/ns/weblogic/920.xsd">
<connection-factory name="Queue_CF_8">
<sub-deployment-name>Server_group_4</sub-deployment-name>
<jndi-name>QUEUE_CF_8</jndi-name>
<security-params>
<attach-jmsx-user-id>false</attach-jmsx-user-id>
</security-params>
</connection-factory>
<uniform-distributed-queue name="DIS_QUEUE_8">
<sub-deployment-name>Server_group_4</sub-deployment-name>
<jndi-name>DIS_QUEUE_8</jndi-name>
<load-balancing-policy>Round-Robin</load-balancing-policy>
</uniform-distributed-queue>
</weblogic-jms>
But the problem was with the clustering.
Thanks for your time.. -
Their original SQL Server was 2008, with SP unknown, but installed on D: and C: drives. The power spike corrupted their O/S on the C:
drive and someone reinstalled both the O/S and the SQL Server, which is now SQL 2008, SP4. They have intact files for all system databases, both .mdb and .ldf. Is there some way they can reconnect with the user databases using the intact copies
of the previous system databases? I have heard that if the SQL Server is stopped, previous Master and Msdb .mdb and .ldf files moved into place and the server restarted, that any previous user database .mdb and .ldf files can be accessed by the SQL server.
Is this the case, or are there details missing?Hello! try this steps
1 Open your SQL Server Management Studio console. This application shortcut is available in the SQL Server directory in the Windows Start button.
2 Enter the system administrator user name and password. SQL Server's administrator user name is "sa." This account is required for privileges to restore the database. If your restoring on a host provider server, use the administrator user name
and password they supplied for your account.
3 Right-click your database name and select "Attach." In the new window that opens, click the "Add" button to open a dialog box.
4 Select your MDF file and press the "Ok" button. It may take several minutes to restore the database if it is a large file. Once the process is finished, browse your tables to verify the data. The database is now restored.
If nothing helped try to use:
https://www.youtube.com/watch?v=1cbOYdvBW2c -
.dat, .mdb and .mpa files
I had to replace my Palm Pre and am trying to re-poplulate my Motion Apps Classic files. My Palm OS files were saved online (Carbonite) and when I go into Carbonite to retrieve my Memo files, they are saved as .dat, .mdb and .mpa files. Can these files a. be imported back into Palm OS, and b. can they be converted to .pdb files?
Thanks
Post relates to: Centro (Sprint)Anand_JAS wrote:
I have the audio and video files extracted from .TS file and stored as
.mpv for video and
.mpa for audio
now i need to merge both files.
finally need to store it as single file like .mpg or some other extention
Please help me regarding this.
Thanks in advance...You use a video editing tool that has this capacity.
- captain obvious -
Difference between static class and singleton?
Hi I wonder what could be the difference between static methods and singleton?
In singleton at any point of time there will be only one object existing in the JVM. We create singleton to avoid multiple object creation for that class.
If I make all the methods in the class as static also it does the same job. The memory will be allocated once. Even there wont be any object in this case, so time required for object creation also can be saved. looks like more efficient but still why need singleton?
This question is also posted in java programming forum. The thread is as follows:-
[Click on this to visit that thread |http://forum.java.sun.com/thread.jspa?threadID=5278517&tstart=0]
Edited by: murrayb9654 on Mar 25, 2008 8:20 AMyawmark wrote:
Static class is a realization of singleton pattern.Not in any conventional sense.
~Especially since a static class is completely different from a class with all static methods. -
Ok,
I am bit confused with how exactly MDBs work with Transactions.
For example,
suppose we have a simple standalone java message producer which sends a message to a Queue. A MDB's onMessage() picks it up.
Let's say the MDB makes some updates to the database and then invokes a method on a stateless session bean which also updates a database.
By default the transaction attribute of the MDB and stateless session bean would be REQUIRED.
If the stateless session bean database update fails, I presume the MDB's database updates also get rolled back.
But, does the message get rolled back? If not when would the message be rolled back?
Does it make any difference if the MDB is a topic or a queue? Does it make any difference if the message producer is a standalone client or
a stateless session bean with it's own transactional behaviour?
Any help appreciated.
Thanks.The general principle is: if you have a MDB which consumes a message in a transaction, and that transaction is rolled back, then the message is "rolled back". This means that it is put back on the queue or topic. It will then be delivered to the MDB again.
If your MDB calls a session bean then the two can share the same global transaction as you suggest.
Note however that the transaction which consumes the message is completely separate from any transaction which placed the message on the queue in the first place. JMS completely decouples the two steps. Once the message is added to the queue the producer is irrelevant.
Nigel -
Differnece between Cardinality and Singleton for a Context Node
Dear SDN Community,
Can you please tell me what is the difference between the Cardinality and Singleton properties for a context node.
Thanks!
SuryaHi Surya
Lead selection
Leadselection is the property which is used to get the index of the selected row of the table
"OnLeadSelect" is the method used to fire an action when a row is selected
The Method wdContext.<node>().getLeadSelection() can be used to
find out the index of the selected element.
Cardinality
Any node or attribute that has the context root node as its immediate parent, is known as an independent node or attribute.
Any node or attribute that has some other node as its immediate parent, is known as a dependent node or attribute.
All context nodes are collections.
A node collection is composed of elements, where an element is an aggregation of the nodes immediate children (attributes and/or other nodes).
The cardinality property controls the number of elements a node collection may hold at runtime.
Every context node has a property called Cardinality. This property is composed of two values that
taken together, describe the maximum and minimum number of elements the node collection may hold
at runtime.
Cardinality Minimum: 0 or 1
Cardinality Maximum: 1 or n
Therefore, there are four possible cardinality values (specified as <Min>..<Max>)
0..1 Zero or one elements permitted
0..n Zero or more elements permitted
1..1 One and only one element permitted
1..n One or more elements permitted
Singleton
All independent nodes are forced to be singletons. This is because the context root node has one and only one element.
Singleton is boolean
TRUE : One instance will be created for all te nodes
FALSE : Every Element in the parent node collection,there will be a distinct instance of the child node.
Why Singleton
-Efficiency
-Less Memory
-Lazy Data Access(Creates instance only when needed,till then it will remain unprocessed)
Supply functions
Supply functions are the mechanism to repopulate child nodes when the lead selection in the parent node
changes. When a singleton child node is declared, you must also write an accompanying supply function.
The Web Dynpro Framework will then automatically call your supply function when the lead selection
in the parent node changes.
Regards
Chaitanya.A -
I have a problem with MDBs and OJMS/AQ. onMessage() method fires well when a message is enqueued, but it is never dequeued. Messages are well received by MDB, but they remain on AQ table without dequeue. Can anybody help me? Thanks
This is bug: Contaner managed transactions do not work with MDBs in OC4J 9.0.3. Either switch to BMT, or use the 10.0.3 preview on OTN.
The bug is fixed in the 9.0.4 production version which is expected "real soon now".
HTH
-Doug -
Thanks for your help Tom,
It turns out I didn't have a transaction. Took a while to track it down...thanks
again...
Tom Barnes <[email protected]> wrote:
>Hi Allen,
>
>Your JDBC configuration looks correct, but I may be wrong. I suggest
>posting to the JDBC newsgroup for confirmation. It might be
>helpful if you post your MDB xml descriptors.
>
>Is your JDBC call embedded directly in the MDB, or does the MDB invoke
>it through another EJB or RMI class?
>
>It seems like there may be no transaction even though you set required?
>To see if the current thread is infected with a live transaction, you
>can insert some trace code:
>Call weblogic.transaction.TxHelper.getTransaction() to get the current
>transaction, then call weblogic.transaction.Transaction.getStatusAsString()
>to
>see its status.
>
>
>Tom
>
>Allen Miller wrote:
>
>> I have a transaction 'required' mdb that essentially instantiates a
>class that
>> does database updates. I get the exception below. It appears the database
>operations
>> are not running as part of the mdb's transaction.
>>
>> I've configured the weblogic supplied oracle xa driver and tx datasourse
>per the
>> doc (as I understand it). The code snippet retrieving the datasource
>and the config.xml
>> definitions follow the exception message below.
>>
>> weblogic 6.1 on win2000
>>
>> any ideas???
>>
>> SQL operations are not allowed with no global transaction by default
>for XA drivers.
>> If the XA driver supports performing SQL operations with no global
>transaction,
>> explicitly allow it by setting "SupportsLocalTransaction" JDBC connection
>pool
>> property to true. In this case, also remember to complete the local
>transaction
>> before using the connection again for global transaction, else a XAER_OUTSIDE
>> XAException may result. To complete a local transaction, you can either
>set auto
>> commit to true or call Connection.commit().
>>
>> Context ctx = new InitialContext();
>> javax.sql.DataSource ds = (javax.sql.DataSource)
>ctx.lookup ("jdbc/" + "ListenPointReporterConnectionsDs");
>> return ds.getConnection();
>>
>> <JDBCConnectionPool CapacityIncrement="1"
>> DriverName="weblogic.jdbc.oci.xa.XADataSource"
>> InitialCapacity="2" LoginDelaySeconds="1" MaxCapacity="15"
>> Name="PlatformListenPointReporterConnections"
>> Properties="user=allen;password=allen;dataSourceName=PlatformListenPointReporterConnections;server=alcatraz;serverName=alcatraz"
>> ShrinkPeriodMinutes="30" ShrinkingEnabled="true"
>> Targets="listenpointServer" TestConnectionsOnRelease="true"
>> TestConnectionsOnReserve="true" TestTableName="LP_USER_V"/>
>>
>> <JDBCTxDataSource EnableTwoPhaseCommit="true"
>> JNDIName="jdbc/ListenPointReporterConnectionsDs"
>> Name="ListenPointReporterConnectionsDs"
>> PoolName="PlatformListenPointReporterConnections" Targets="listenpointServer"/>
>
-
Hello,
I was wondering if anyone else has experienced this problem and/or can suggest a solution...btw, I'm running this on JRun4.
I have a JMS queue that uses a database for the queue. The onMessage method for my MDB is part of a container managed transaction. My onMessage method simply inserts the message into an audit table. I then purposely change the name of the audit table so that my MDB will throw a SQLException.
If I send a single message, a SQL exception is thrown and caught and I roll back the transaction via MessageDrivenContext.setRollbackOnly(). The stdout logs show that after the exception the transaction is rolled back and the message is resent. This sequence occurs repeatedly until I fix the column name and then the message is consumed and inserted in my audit table. This works as I expect.
If I were to send 2 (or more) messages, the same SQL exception occurs for each message and the transaction is rolled back and the message(s) are resent. However, once I fix the table error, I find that those 2 messages were repeatedly consumed and inserted into the audit table (e.g. there were 50+ inserts). In the stdout logs it appears once the database problem is corrected each transaction that was rolled back now ends up commiting leading to repeat consumptions.
Has anyone encountered this? I'm a bit confused as to why, since the rollbacks, resends, and commits appear to work fine when there is only a single message.
Any suggestions? Thanks.This is only a guess, but I'd say that the implementation isn't using two-phase commit aware resources (XAResources) to coordinate modifications to the backend database table. If you're only using a single resource (message in your case) then it's fine to use raw JDBC and turn auto-commit off; the application or container can then use the JDBC driver commit or rollback operations to make the change to the table happen (or not). If you're doing multiple updates through the same JDBC driver within the same global transaction then this still works.
I wonder if the implementation is somehow adding each message through a separate JDBC instance (even though to the same back end DM) and committing each prior to doing work on the next message. This commit may not be explicit. You may not even know it is going on: for example, if the back end db is Oracle, if you do a close on a JDBC connection which is running in a transaction then it will implicitly commit the transaction at that point.
For instance:
receive message
get JDBC connection
add message to table
close JDBC connection (may be explicit or may be implicit via the container)
<-- commit happens here in some cases
receive message
get JDBC connection
add message to table
What the implementation really should use is XADataSources and XAConnections to get XAResources that coordinate updates to the database. Or, make sure the same JDBC connection is used within the same transaction. This is more difficult to coordinate because of close. -
MDB and Database - Listener port stops working
Hi,
I have created an MDB which does the following when a message is received from the queue.
1. Store message in database
2. do some processing
At step 1, if there is any issue with the database connection (e.g. database is not available etc), I rollback transaction. My idea is to leave the message on queue for now and retry it again after some time unless the database is back again. "Maximum retries" of the listener port is set to N but since there is no retry interval available, all N retries are done in a flash and my listener port stops working. I cannot use backout mechanism as I have to wait for the database to be back again. What are my options?usmanchaudhry wrote:
Hi,
I have created an MDB which does the following when a message is received from the queue.
1. Store message in database
2. do some processing
At step 1, if there is any issue with the database connection (e.g. database is not available etc), I rollback transaction. My idea is to leave the message on queue for now and retry it again after some time unless the database is back again. "Maximum retries" of the listener port is set to N but since there is no retry interval available, all N retries are done in a flash and my listener port stops working. I cannot use backout mechanism as I have to wait for the database to be back again. What are my options?i believe you need an XA driver and a transaction manager, for starters.
a simple JDBC rollback won't do it.
which app server are you using?
which jms provider?
% -
Hi ,
I have an MDB running on weblogic 8.2 and calling a remove ejb running on a different machine. After getting home interface when I tried to create the remote object Iam getting the following error.
java.lang.NullPointerException
at weblogic.transaction.internal.PropagationContext.useNewMethod(PropagationContext.java:866)
at weblogic.transaction.internal.PropagationContext.writeExternal(PropagationContext.java:169)
at weblogic.common.internal.ChunkedObjectOutputStream.writeObject(ChunkedObjectOutputStream.java:100)
at weblogic.common.internal.ChunkedObjectOutputStream.writeObjectWL(ChunkedObjectOutputStream.java:122)
at weblogic.rjvm.MsgAbbrevOutputStream.setTxContext(MsgAbbrevOutputStream.java:122)
at weblogic.rjvm.BasicOutboundRequest.setTxContext(BasicOutboundRequest.java:156)
at weblogic.rmi.internal.BasicRemoteRef.getOutboundRequest(BasicRemoteRef.java:106)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:276)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:244)
Can any body tell what could be the reason. The message sent from MDB to ejb is a transactional message.
Thanks in advance
ManikyalaI suggest posting to the EJB newsgroup.
(1) Transactions certainly are supported for remote services. This is a common use case.
(2) Your problem seemed to occur when getting the remote home - but likely would not occur when actually using it. Since I think (not 100% sure) that the action of obtaining the remote home need not be transactional, I previously suggested suspending the transactions, but only for the duration of the call to get the remote home.
Tom
> Hi Tom,
>
> Looks like what Iam doing is not correct.
>
> Iam calling a remote ejb which on a different server
> from my MDB. Iam using t3 to get the context. Also in
> the weblogic-ejb-jar.xml I put transaction value as
> Required.
>
> Now I replaced that with NotSupported and problem is
> solved.
>
> The conclusion is (if Iam not wrong) when creating a
> remote home we should not use transactions since the
> remote service is not participating in transaction.
>
> Thanks again Tom
>
>
> Manikyala
Maybe you are looking for
-
"Page not found" error after 5 minutes of see "processing" on the screen
We are using WebLogic 8.1 server and also the WebLogic proxy as our front end. When a user runs a process that takes over 5 minutes using the Proxy URL they receive an IE "Page not found" error after 5 minutes of seeing "processing" on the screen. If
-
New iPad device not recognised
Bought new iPad for son's birthday. Device not showing in iTunes and not charging. Tried several computers and another cable. Tried troubleshooting and deed dive in iPad troubleshooting manual. What is going on? I think this is faulty and just came o
-
For-Each/Group by...problem
Hi, I have a sample xml below <root> <objective-sect index="3"> <fm-objective index="1" removable="true"> <fm-obj-name>value 01</fm-obj-name> </fm-objective> <fm-objective index="2" removable="true"> <fm-obj-name>value 02</fm-obj-name> </fm-objective
-
Making a printable return envelope attatched to form
Hi guys, I have made a really nice invoice form and would like to include a return envelope with the company mailing address and populated with the customers return address from the invoice form that could be printed. So far I have tried the # 10 env
-
Hi I have Copy Standard Adobe Form and used it with the logo and minor adjustment . when i see it in preview it doesn't show any fields , but when i call it and data come on the page it shows all the field properly. How can i set fields invisible wit