Transaction Session, Rollback and Redelivery
Well, apparently this is a bug in Weblogic 6.1 up to sp2. (I can not comment if this
bug either exists or does not exist in 6.0 and below or 7.0 and above.) Bug ID is
:CR080301 if this is impacting anyone else. I'll post the final outcome and if
it gets fixed.
(I would also ask everyone if you post a question and end up going to BEA, customer
support, if you could post the outcome, that would make everyone's life so much easier.)
To respond to me via E-mail, simply pull the weeds. =)
Tom Barnes <[email protected]> wrote:
>Hi Mike,
>
>As far as I know, Zach's response still stands. The behavior you are seeing,
>given
>the limited information posted, doesn't ring any bells. Please forward
>your issue to
>customer
>support, with enough information to reproduce along with a SP number and
>thread-dumps.
>They will know if your particular problem has been seen before...
>
>If you like, post your reproducer code here, with thread-dumps.
>
>Tom
>
>P.S. Email addresses on this forum tend to be "bogus" because this is not
>a formal
>forum. Think of it as a free Anne Landers for JMS. Posters are volunteers,
>posting
>on "their own time".
>
>Mike Wiles wrote:
>
>> Was there ever any outcome to this issue? I am experiencing the same
>behavior and
>> since both of these E-mail addresses are pretty much bogus, it is impossible
>to get
>> some sort of follow-up.
>>
>> Mike
>>
>> To send me an E-mail, simply pull the WEEDS.
>>
>> "Zach" <[email protected]> wrote:
>> >Very strange behavior. You should file a support case.
>> >_sjz.
>> >
>> >"Bart Simpson" <[email protected]> wrote in message
>> >news:[email protected]...
>> >>
>> >> Hi,
>> >>
>> >> I am trying to understand, how rollback works with transaction session
>> >in
>> >WLS
>> >> 6.1 sp1. What should happen when session.rollback() is called? After
>> >calling
>> >> rollback() couple of times, the server program receiving the messages
>> >just
>> >hangs?
>> >> I have configured redelivery delay to 3000 and redelivery tries to
>3.
>> >However,
>> >> if I restart the server program, then I see the normal redelivery
>> >happening again.
>> >> Is this a feature or bug?
>> >>
>> >> Here is the client program:
>> >> package com.malani.jms.client;
>> >>
>> >> import java.util.*;
>> >>
>> >> import javax.jms.*;
>> >> import javax.naming.*;
>> >>
>> >> import com.malani.jms.resources.*;
>> >>
>> >> public class Client {
>> >>
>> >> public static void sendMessage(QueueSender aSender, Session aSession,
>> >int
>> >> i)
>> >> throws JMSException
>> >> {
>> >> aSender.send(aSession.createTextMessage("" + i));
>> >> }
>> >>
>> >> public static void printUsage() {
>> >> System.out.println("Usage:");
>> >> System.out.println(Client.class.getName() + " jndi_queue_name");
>> >> System.exit(1);
>> >> }
>> >>
>> >> public static void main(String[] args) {
>> >> if (args.length != 1) {
>> >> printUsage();
>> >> }
>> >>
>> >> QueueSender aSender = null;
>> >> QueueSession aSession = null;
>> >> QueueConnection aConnection = null;
>> >> try {
>> >> Properties p = new Properties();
>> >>
>> >p.load(JMSProperties.class.getResourceAsStream("jms.properties"));
>> >> InitialContext aIC = new InitialContext(p);
>> >> QueueConnectionFactory aFactory = (QueueConnectionFactory)
>> >aIC.lookup(
>> >> p.getProperty("queue.connection.factory.name")
>> >> );
>> >> aConnection = aFactory.createQueueConnection();
>> >> aConnection.start();
>> >> aSession = aConnection.createQueueSession(
>> >> false,
>> >> QueueSession.AUTO_ACKNOWLEDGE
>> >> );
>> >> Queue aQueue = (Queue) aIC.lookup(args[0].trim());
>> >> aSender = aSession.createSender(aQueue);
>> >>
>> >> int i = 0;
>> >> for (; i < 20; i++) {
>> >> sendMessage(aSender, aSession, i);
>> >> }
>> >> } catch (Exception e) {
>> >> e.printStackTrace();
>> >> } finally {
>> >> try {
>> >> if (aSender != null) {
>> >> aSender.close();
>> >> }
>> >> } catch (JMSException e) {}
>> >> try {
>> >> if (aSession != null) {
>> >> aSession.close();
>> >> }
>> >> } catch (JMSException e) {}
>> >> try {
>> >> if (aConnection != null) {
>> >> aConnection.stop();
>> >> aConnection.close();
>> >> }
>> >> } catch (JMSException e) {}
>> >> }
>> >> }
>> >> }
>> >>
>> >> Here is the server program:
>> >> package com.malani.jms.transaction;
>> >>
>> >> import java.util.*;
>> >>
>> >> import javax.jms.*;
>> >> import javax.naming.*;
>> >>
>> >> import com.malani.jms.resources.*;
>> >>
>> >> public class Server {
>> >> public static final String JNDI_QUEUE_NAME =
>> >"transaction_queue_jndi_name";
>> >>
>> >> public static void main(String[] args) {
>> >> QueueReceiver aReceiver = null;
>> >> QueueSession aSession = null;
>> >> QueueConnection aConnection = null;
>> >> try {
>> >> Properties p = new Properties();
>> >>
>> >p.load(JMSProperties.class.getResourceAsStream("jms.properties"));
>> >> InitialContext aIC = new InitialContext(p);
>> >> QueueConnectionFactory aFactory = (QueueConnectionFactory)
>> >aIC.lookup(
>> >> p.getProperty("queue.connection.factory.name")
>> >> );
>> >> aConnection = aFactory.createQueueConnection();
>> >> aConnection.start();
>> >> aSession = aConnection.createQueueSession(
>> >> true,
>> >> -1 // doesn't really matter
>> >> );
>> >> Queue aQueue = (Queue) aIC.lookup(JNDI_QUEUE_NAME);
>> >> aReceiver = aSession.createReceiver(aQueue);
>> >> final QueueSession aQS = aSession;
>> >> MessageListener aML = new MessageListener() {
>> >> public void onMessage(Message m) {
>> >> try {
>> >> TextMessage aTM = (TextMessage) m;
>> >> String s = aTM.getText();
>> >> System.out.println("Text is:\t" + s);
>> >> int i = Integer.parseInt(s);
>> >> if (i < 15) {
>> >> aQS.commit();
>> >> } else {
>> >> aQS.rollback();
>> >> }
>> >> } catch (JMSException e) {
>> >> e.printStackTrace();
>> >> }
>> >> }
>> >> };
>> >> aReceiver.setMessageListener(aML);
>> >> byte[] b = new byte[1];
>> >> System.in.read(b);
>> >> } catch (Exception e) {
>> >> e.printStackTrace();
>> >> } finally {
>> >> try {
>> >> if (aReceiver != null) {
>> >> aReceiver.close();
>> >> }
>> >> } catch (JMSException e) {}
>> >> try {
>> >> if (aSession != null) {
>> >> aSession.close();
>> >> }
>> >> } catch (JMSException e) {}
>> >> try {
>> >> if (aConnection != null) {
>> >> aConnection.stop();
>> >> aConnection.close();
>> >> }
>> >> } catch (JMSException e) {}
>> >> }
>> >> }
>> >> }
>> >>
>> >> Here is the properties file:
>> >> #
>> >> java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
>> >> java.naming.provider.url=t3://localhost:7001
>> >> queue.connection.factory.name=weblogic.jms.ConnectionFactory
>> >>
>> >#queue.connection.factory.name=weblogic.jms.MessageDrivenBeanConnectionFacto
>> >ry
>> >> #queue.connection.factory.name=transaction_connection_factory_jndi_name
>> >>
>> >> Here is the JMSProperties file:
>> >> package com.malani.jms.resources;
>> >>
>> >> public class JMSProperties {
>> >> }
>> >>
>> >> The first time the server is run, it hangs at 16. Messages 17, 18,
>and
>> >19
>> >are
>> >> not processed. Is this correct behavior:
>> >> Text is: 0
>> >>
>> >> Text is: 1
>> >>
>> >> Text is: 2
>> >>
>> >> Text is: 3
>> >>
>> >> Text is: 4
>> >>
>> >> Text is: 5
>> >>
>> >> Text is: 6
>> >>
>> >> Text is: 7
>> >>
>> >> Text is: 8
>> >>
>> >> Text is: 9
>> >>
>> >> Text is: 10
>> >>
>> >> Text is: 11
>> >>
>> >> Text is: 12
>> >>
>> >> Text is: 13
>> >>
>> >> Text is: 14
>> >>
>> >> Text is: 15
>> >>
>> >> Text is: 16
>> >>
>> >>
>> >> What happened to message 17, 18, and 19?
>> >>
>> >> Now, if I stop the server, and start it again, I see the requequing
>and
>> >redelivery
>> >> of the messages as shown below:
>> >> Text is: 15
>> >>
>> >> Text is: 16
>> >>
>> >> Text is: 17
>> >>
>> >> Text is: 18
>> >>
>> >> Text is: 19
>> >>
>> >> Text is: 15
>> >>
>> >> Text is: 17
>> >>
>> >> Text is: 16
>> >>
>> >> Text is: 18
>> >>
>> >> Text is: 19
>> >>
>> >> Text is: 15
>> >>
>> >> Text is: 17
>> >>
>> >> Text is: 16
>> >>
>> >> Text is: 18
>> >>
>> >> Text is: 19
>> >>
>> >> Text is: 17
>> >>
>> >> Text is: 18
>> >>
>> >> Text is: 19
>> >>
>> >>
>> >> Is there some optimization going on?
>> >>
>> >> Thank you so much....
>> >>
>> >>
>> >
>> >
>
Similar Messages
-
Session method and call transaction methos which one is the sap recomonded
hi
PLease give me the answer to these questions.
session method and call transaction methos which one is the sap recomonded why .
2) if we want to maintain BDC program in all the systems.wt to d0Hi Revethi,
Here is the difference between the Session and Call Transaction method.
Session
Session method supports both small amount of data aswell as large amount of data
2) data processing is asynchronus and data updation is synchronus.
3) it process multiple apllication while perfomaning validations.
4) in session method data will be updated in data base only after processing session only.
5) system provide by default logfile for handling error records.
6) it supports both foreground aswell as background process
in bdc we use FM ... bdc_open_group " for creating Session
bdc_insert " adding transaction and bdcdata table for updating database
bdc_close_group " for closing Session
Call Transaction
Call transaction exclusively for small amout of data
2) it supports only one apllication while perfoming validations
3) there is no default logfile, We can explicitly provide logic for creating logfile for handling error records.
we can create logfile by using structure....BDCMSGCOLL
4) it doesn't support background processing.
5) data processing is synchronous and Data updation is Synchronous( default), in
this method also supports daya updation in asynchronus process also.
Syntax:
Call transaction <transaction-name> using BDCDATA
mode <A/N/E> update <L/A/S>
messages into BDCMSGCOLL. -
Difference between Session method and call transaction
Hi,
please give me the differences between session method and call transaction,
briefly explaining synchronus , asynchronus, process, update.
Thanks in advanceHi Vijay Kumar
CLASSICAL BATCH INPUT (Session Method)
CALL TRANSACTION
BATCH INPUT METHOD:
This method is also called as CLASSICAL METHOD.
Features:
Asynchronous processing.
Synchronous Processing in database update.
Transfer data for more than one transaction.
Batch input processing log will be generated.
During processing, no transaction is started until the previous transaction has been written to the database.
CALL TRANSACTION METHOD :
This is another method to transfer data from the legacy system.
Features:
Synchronous processing. The system performs a database commit immediately before and after the CALL TRANSACTION USING statement.
Updating the database can be either synchronous or asynchronous. The program specifies the update type.
Transfer data for a single transaction.
Transfers data for a sequence of dialog screens.
No batch input processing log is generated.
http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
Among the two methods call transaction is better compared to session bcoz data transfer is faster in it.
Differences between call transaction and session.
Session Method:
1) Data is not updated in the database table until the session is processed.
2) No sy-subrc is returned.
3) Error log is created for error records.
4) Updation is always synchronous.
Call Transaction Method:
1) Immediate updation in the database table.
2) sy-subrc is returned.
3)Error need to be handled explicitly.
4) updation can be synchronous as well as asynchronous.
2) ya u can use using the N mode no screen.
3)u can't handle multiple transaction in call transaction.
4) u can handle multiple transaction in session using the BDC_INSERT fm.
5)When u go to SM35 u can able to see the error records.
Which is best?
That depends on your requirement. Both of them have there advantages.
According to the situation u can choose any one of these.
difference between batch input and call transaction in BDC Session method.
1) synchronous processing.
2) can tranfer large amount of data.
3) processing is slower.
4) error log is created
5) data is not updated until session is processed.
Call transaction.
1) asynchronous processing
2) can transfer small amount of data
3) processing is faster.
4) errors need to be handled explicitly
5) data is updated automatically
For session method,these are the function modules to b used.
BDC_OPEN_GROUP
BDC_INSERT
BDC_CLOSE_GROUP
For call transaction,this is the syntax.
CALL TRANSACTION TCODE USING BDCDATA
MODE A or E or N
UPDATE A or S
MESSAGES INTO MESSTAB.
Take a scenario where we need to post documents in FB01 and the input file has say 2000 records (2000 documents, not line items in FB01 but 2000 records)
In the BDC call transaction method
We call the transaction FB01 2000 times (once for each record posting) and if the processing fails in record no 3 it can be captured and start with reocord 4.
Eg: Loop at itab.
call transaction FB01
capture errors
endloop.
In the session method.
We do not explicity call the transaction 2000 times, but all the records are appeneded into a session and this session is stored. The processinf of the session is done wwhenever the user wants it to be done. Hence the errors cannot be captured in the program itself
Check these link:
http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
http://www.sap-img.com/abap/question-about-bdc-program.htm
http://www.itcserver.com/blog/2006/06/30/batch-input-vs-call-transaction/
http://www.planetsap.com/bdc_main_page.htm
Batch Input Session method is asynchronous as told by others here. But the advantage of this is that you have all the error messages and the data for each transaction held persistantly. You don't have to code anything for processing them or writing the logs.
But at the same time, the same feature can be disadvantageous if you need to react to an error or if there are too many errors to manually correct in a session. Since the session are created in the program and its execution is done seperately, you loose the trackability of such transactions.
With a call transaction, what was a disadvantage above will become an advantage. Call transaction immediately gives you messages back and you can react to it in your program. But the disadvantage is that, if you have several hundreds of transactions to run, running them from within the program can be resource crunching affair. It will hamper the system performance and you cannot really distribute the load. Of course, you have some mechanisms with which you can overcome this, but you will have to code for it. Also, storing the messages and storing the errored transaction data etc will have to be handled by you in the program. Whereas, in batch input session, your program's job is to just create the session, after that everything is standard SAP system's responsibility.
Ideally, you should do a call transaction if the resources are not a problem and if it fails, put the errored transaction into a session.
You can decide based on the data volume that your BDC is processing. If data volume is high go for session else call transaction will do.The call transaction updates will be instantaneous where as session needs to be processed explictly after creation.
Session Method
1) Session method supports both small amount of data aswell as large amount of data
2) data processing is asynchronus and data updation is synchronus.
3) it process multiple apllication while perfomaning validations.
4) in session method data will be updated in data base only after processing session only.
5) system provide by default logfile for handling error records.
6) it supports both foreground aswell as background process
in bdc we use FM ...
bdc_open_group " for creating Session
bdc_insert " adding transaction and bdcdata table for updating database
bdc_close_group " for closing Session
Call Transaction
1) Call transaction exclusively for small amout of data
2) it supports only one apllication while perfoming validations
3) there is no default logfile, We can explicitly provide logic for creating logfile for handling error records.
we can create logfile by using structure....BDCMSGCOLL
4) it doesn't support background processing.
5) data processing is synchronous and Data updation is Synchronous( default), in
this method also supports daya updation in asynchronus process also.
syntax:
Call transaction <transaction-name> using BDCDATA
mode <A/N/E>
update <L/A/S>
messages into BDCMSGCOLL.
BDC:
Batch Data Communication (BDC) is the process of transferring data from one SAP System to another SAP system or from a non-SAP system to SAP System.
Features :
BDC is an automatic procedure.
This method is used to transfer large amount of data that is available in electronic medium.
BDC can be used primarily when installing the SAP system and when transferring data from a legacy system (external system).
BDC uses normal transaction codes to transfer data.
Types of BDC :
CLASSICAL BATCH INPUT (Session Method)
CALL TRANSACTION
BATCH INPUT METHOD:
This method is also called as CLASSICAL METHOD.
Features:
Asynchronous processing.
Synchronous Processing in database update.
Transfer data for more than one transaction.
Batch input processing log will be generated.
During processing, no transaction is started until the previous transaction has been written to the database.
CALL TRANSACTION METHOD :
This is another method to transfer data from the legacy system.
Features:
Synchronous processing. The system performs a database commit immediately before and after the CALL TRANSACTION USING statement.
Updating the database can be either synchronous or asynchronous. The program specifies the update type.
Transfer data for a single transaction.
Transfers data for a sequence of dialog screens.
No batch input processing log is generated.
For BDC:
http://myweb.dal.ca/hchinni/sap/bdc_home.htm
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/bdc&
http://www.sap-img.com/abap/learning-bdc-programming.htm
http://www.sapdevelopment.co.uk/bdc/bdchome.htm
http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
http://help.sap.com/saphelp_47x200/helpdata/en/69/c250684ba111d189750000e8322d00/frameset.htm
http://www.sapbrain.com/TUTORIALS/TECHNICAL/BDC_tutorial.html
Check these link:
http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
http://www.sap-img.com/abap/question-about-bdc-program.htm
http://www.itcserver.com/blog/2006/06/30/batch-input-vs-call-transaction/
http://www.planetsap.com/bdc_main_page.htm
call Transaction or session method ?
Check the following links:
http://www.sap-img.com/bdc.htm
See below example code :
Call three FM : BDC_OPEN_GROUP,BDC_INSERT and BDC_CLOSE_GROUP.
Once you execute the program and it creates the session at SM35 Transaction.
Report : ZMPPC011
Type : Data upload
Author : Chetan Shah
Date : 05/05/2005
Transport : DV3K919557
Transaction: ??
Description: This ABAP/4 Program creates new Production Versions
(C223). It accepts tab-delimited spreadsheet input and
creates BDC sessions.
Modification Log
Date Programmer Request # Description
06/10/2005 Chetan Shah DV3K919557 Initial coding
report zmppc011 no standard page heading line-size 120 line-count 55
message-id zz.
pool of form routines
include zmppn001.
Define BDC Table Structure
data: begin of itab_bdc_tab occurs 0.
include structure bdcdata.
data: end of itab_bdc_tab.
Input record layout of Leagcy File
data: begin of itab_xcel occurs 0,
matnr(18) type c,
werks(4) type c,
alnag(2) type c,
verid(4) type c,
text1(40) type c,
bstmi like mkal-bstmi,
bstma like mkal-bstma,
adatu(10) type c,
bdatu(10) type c,
stlal(2) type c,
stlan(1) type c,
serkz(1) type c,
mdv01(8) type c,
elpro(4) type c,
alort(4) type c,
end of itab_xcel.
data: begin of lt_pp04_cache occurs 0,
matnr like itab_xcel-matnr,
werks like itab_xcel-werks,
alnag like itab_xcel-alnag,
plnnr like mapl-plnnr,
arbpl like crhd-arbpl,
ktext like crtx-ktext,
end of lt_pp04_cache.
data: v_ssnnr(4) type n,
v_lines_in_xcel like sy-tabix,
v_ssnname like apqi-groupid,
v_trans_in_ssn type i,
wa_xcel LIKE itab_xcel,
l_tabix like sy-tabix,
v_matnr like rc27m-matnr,
v_plnnr like mapl-plnnr,
v_plnal like mapl-plnal,
v_tcode like sy-tcode value 'C223',
v_plnty like plas-plnty value 'R',
v_objty like crhd-objty value 'A',
v_plpo_steus like plpo-steus value 'PP04',
v_verwe like crhd-verwe value '0007'.
Parameters
selection-screen: skip 3.
selection-screen: begin of block 1 with frame.
parameters: p_name like rlgrap-filename
default 'C:\My Documents\InputFile.txt'
obligatory,
bdc session name prefix
p_bdcpfx(6) default 'ZPVCRT'
obligatory,
number for transction per BDC session
p_trnssn type i
default 2000 obligatory,
retain the BDC session after successfull execution
p_keep like apqi-qerase
default 'X',
user who will be executing BDC session
p_uname like apqi-userid
default sy-uname
obligatory.
selection-screen: end of block 1.
possible entry list (F4 dropdown) for input file name
at selection-screen on value-request for p_name.
*-SELECT FILE FROM USERS LOCAL PC
call function 'WS_FILENAME_GET'
exporting
DEF_FILENAME = ' '
def_path = 'C:\Temp\'
mask = ',.,..'
mode = 'O'
title = 'Select File '(007)
importing
filename = p_name
RC =
exceptions
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
others = 5.
if sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
begin the show
start-of-selection.
read data from input file
perform transfer_xcel_to_itab.
loop at itab_xcel.
hang on to xcel line num
l_tabix = sy-tabix.
each line in the xcel file marks begining of new prod.version defn
if num-of-trnas-in-session = 0, create new BDC session
if v_trans_in_ssn is initial.
perform bdc_session_open.
endif.
begin new bdc script for rtg create trans
fill in bdc-data for prod.version maintenance screens
perform bdc_build_script.
insert the bdc script as a BDC transaction
perform bdc_submit_transaction.
keep track of how many BDC transactions were inserted in the BDC
session
add 1 to v_trans_in_ssn.
if the user-specified num of trans in BDC session is reached OR
if end of input file is reached, close the BDC session
if v_trans_in_ssn = p_trnssn or
l_tabix = v_lines_in_xcel.
perform bdc_session_close.
clear v_trans_in_ssn.
endif.
endloop.
top-of-page.
call function 'Z_HEADER'
EXPORTING
FLEX_TEXT1 =
FLEX_TEXT2 =
FLEX_TEXT3 =
FORM TRANSFER_XCEL_TO_ITAB *
Transfer Xcel Spreadsheet to SAP Internal Table *
form transfer_xcel_to_itab.
Read the tab-delimited file into itab
call function 'WS_UPLOAD'
exporting
filename = p_name
filetype = 'DAT'
IMPORTING
filelength = flength
tables
data_tab = itab_xcel
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_table_width = 4
invalid_type = 5
no_batch = 6
unknown_error = 7
others = 8.
if sy-subrc = 0.
sort the data
sort itab_xcel by matnr werks.
clear v_lines_in_xcel.
if no data in the file - error out
describe table itab_xcel lines v_lines_in_xcel.
if v_lines_in_xcel is initial.
write: / 'No data in input file'.
stop.
endif.
else.
if file upload failed - error out
write: / 'Error reading input file'.
stop.
endif.
endform.
FORM BDC_SESSION_OPEN *
Open BDC Session *
form bdc_session_open.
create bdc session name = prefix-from-selectn-screen + nnnn
add 1 to v_ssnnr.
concatenate p_bdcpfx v_ssnnr into v_ssnname.
open new bdc session
call function 'BDC_OPEN_GROUP'
exporting
client = sy-mandt
group = v_ssnname
keep = p_keep
user = p_uname
exceptions
client_invalid = 1
destination_invalid = 2
group_invalid = 3
group_is_locked = 4
holddate_invalid = 5
internal_error = 6
queue_error = 7
running = 8
system_lock_error = 9
user_invalid = 10
others = 11.
endform.
FORM BDC_BUILD_SCRIPT *
Build BDC *
form bdc_build_script.
data: l_arbpl like crhd-arbpl,
l_text1 like mkal-text1,
l_mdv01 like mkal-mdv01,
l_mapl like mapl.
clear bdc-data itab - begin of new bdc transaction
clear itab_bdc_tab.
refresh itab_bdc_tab.
read material cross reference tables to determine sap part#
clear : v_matnr, v_plnnr, v_plnal.
perform read_matnr_cross_ref using itab_xcel-matnr
itab_xcel-werks
changing v_matnr.
determine the version description to use
if itab_xcel-text1 is initial.
l_text1 = itab_xcel-verid.
else.
l_text1 = itab_xcel-text1.
endif.
determine the routing group# and group ctr# to use
perform read_routing .
determine the production line to use
if itab_xcel-mdv01 is initial.
if not provided in the file then:
prod line = work ctr on the last PP04 op of the rtg determined above
perform read_wc_on_last_pp04 using v_plnnr v_plnal
changing l_mdv01.
NOTE: when executing the above form\routine, if v_plnnr is initial
or v_plnal is initial, THEN l_mdv01 will automatically be
returned blank (ie initial)
else.
l_mdv01 = itab_xcel-mdv01.
endif.
build bdc script
perform bdc_build_script_record
fill in initial screen
using: 'X' 'SAPLCMFV' '1000',
' ' 'BDC_OKCODE' '=ENTE',
' ' 'MKAL-WERKS' itab_xcel-werks,
' ' 'MKAL-MATNR' v_matnr,
' ' 'MKAL_ADMIN-DISPO' space,
' ' 'MKAL-PLNNR' space,
' ' 'MKAL_ADMIN-STTAG' space,
' ' 'MKAL-PLNNG' space,
' ' 'MKAL-MDV01' space,
' ' 'MKAL-PLNNM' space,
click create button on initial screen and go to detail screen
'X' 'SAPLCMFV' '1000',
' ' 'BDC_OKCODE' '=CREA',
fill in the detail screen and go back to initial screen
'X' 'SAPLCMFV' '2000',
' ' 'BDC_OKCODE' '=CLOS',
' ' 'MKAL_EXPAND-MATNR' v_matnr,
' ' 'MKAL_EXPAND-VERID' itab_xcel-verid,
' ' 'MKAL_EXPAND-TEXT1' l_text1,
' ' 'MKAL_EXPAND-BSTMI' itab_xcel-bstmi,
' ' 'MKAL_EXPAND-BSTMA' itab_xcel-bstma,
' ' 'MKAL_EXPAND-ADATU' itab_xcel-adatu,
' ' 'MKAL_EXPAND-BDATU' itab_xcel-bdatu,
' ' 'MKAL_EXPAND-PLTYG' v_plnty,
' ' 'MKAL_EXPAND-PLNNG' v_plnnr,
' ' 'MKAL_EXPAND-ALNAG' v_plnal,
' ' 'MKAL_EXPAND-STLAL' itab_xcel-stlal,
' ' 'MKAL_EXPAND-STLAN' itab_xcel-stlan,
' ' 'MKAL_EXPAND-SERKZ' itab_xcel-serkz,
' ' 'MKAL_EXPAND-MDV01' l_mdv01,
' ' 'MKAL_EXPAND-ELPRO' itab_xcel-elpro,
' ' 'MKAL_EXPAND-ALORT' itab_xcel-alort,
save the production version from initial screen
'X' 'SAPLCMFV' '1000',
' ' 'BDC_OKCODE' '=SAVE'.
endform.
FORM BDC_SUBMIT_TRANSACTION *
Submit BDC Session *
form bdc_submit_transaction.
Load BDC script as a trqansction in BDC session
call function 'BDC_INSERT'
exporting
tcode = v_tcode
tables
dynprotab = itab_bdc_tab
exceptions
internal_error = 01
not_open = 02
queue_error = 03
tcode_invalid = 04.
endform.
FORM BDC_BUILD_SCRIPT_RECORD *
form bdc_build_script_record using dynbegin name value.
clear itab_bdc_tab.
if dynbegin = 'X'.
move: name to itab_bdc_tab-program,
value to itab_bdc_tab-dynpro,
'X' to itab_bdc_tab-dynbegin.
else.
move: name to itab_bdc_tab-fnam,
value to itab_bdc_tab-fval.
shift itab_bdc_tab-fval left deleting leading space.
endif.
append itab_bdc_tab.
endform.
FORM BDC_SESSION_CLOSE *
Close BDC Session *
form bdc_session_close.
close the session
call function 'BDC_CLOSE_GROUP'
exceptions
not_open = 1
queue_error = 2
others = 3.
skip 2.
if sy-subrc ne 0.
write: / 'Error Closing BDC Session ' , 'RETURN CODE: ', sy-subrc.
else.
write : / 'Session created:', v_ssnname,
50 '# of transactions:', v_trans_in_ssn.
endif.
endform.
*& Form read_routing_cache
*FORM read_routing_cache USING pi_matnr
pi_werks
pi_alnag
pi_verid
pi_mdv01.
DATA: BEGIN OF lt_plpo OCCURS 0,
vornr LIKE plpo-vornr,
objty LIKE crhd-objty,
objid LIKE crhd-objid,
arbpl LIKE crhd-arbpl,
END OF lt_plpo,
l_mapl_plnnr LIKE mapl-plnnr.
determine the routing group#
CLEAR lt_pp04_cache.
chk if its in the cache first, if not then get it from MAPL table
and put it in the cache
READ TABLE lt_pp04_cache WITH KEY matnr = pi_matnr
werks = pi_werks
alnag = pi_alnag.
IF sy-subrc = 0.
do nothing - lt_pp04_cache header line has rtg#
ELSE.
get the routing group # from MAPL
SELECT plnnr INTO l_mapl_plnnr
FROM mapl UP TO 1 ROWS
WHERE matnr = pi_matnr AND
werks = pi_werks AND
plnty = 'R' AND
plnal = pi_alnag AND
loekz = space.
ENDSELECT.
put it in the cache internal table
IF NOT l_mapl_plnnr IS INITIAL.
lt_pp04_cache-matnr = pi_matnr.
lt_pp04_cache-werks = pi_werks.
lt_pp04_cache-alnag = pi_alnag.
lt_pp04_cache-plnnr = l_mapl_plnnr.
APPEND lt_pp04_cache.
ENDIF.
ENDIF.
if the rtg# was determined AND
-- the work center was not determined yet AND
-- work center was really needed for this line in the input file
then
-- read the work center from last PP04 operation on the routing
-- update the cache accordingly
IF NOT lt_pp04_cache-plnnr IS INITIAL AND
lt_pp04_cache-arbpl IS INITIAL AND
( pi_verid IS INITIAL OR
pi_mdv01 IS INITIAL ).
read the last PP04 operation
CLEAR lt_plpo.
REFRESH lt_plpo.
SELECT vornr eobjty eobjid e~arbpl
INTO CORRESPONDING FIELDS OF TABLE lt_plpo
FROM plas AS b
INNER JOIN plpo AS c
ON bplnty = cplnty AND
bplnnr = cplnnr AND
bzaehl = czaehl
INNER JOIN crhd AS e
ON carbid = eobjid
WHERE b~plnty = v_plnty AND
b~plnnr = lt_pp04_cache-plnnr AND
b~plnal = lt_pp04_cache-alnag AND
c~loekz = space AND
c~steus = v_plpo_steus AND
e~objty = v_objty AND
e~werks = lt_pp04_cache-werks AND
e~verwe = v_verwe.
SORT lt_plpo BY vornr DESCENDING.
READ TABLE lt_plpo INDEX 1.
IF NOT lt_plpo-arbpl IS INITIAL.
lt_pp04_cache-arbpl = lt_plpo-arbpl.
read work center description
SELECT SINGLE ktext INTO lt_pp04_cache-ktext
FROM crtx WHERE objty = lt_plpo-objty AND
objid = lt_plpo-objid AND
spras = sy-langu.
the following read will get the index of the correct record to be
updated in the cache
READ TABLE lt_pp04_cache
WITH KEY matnr = pi_matnr
werks = pi_werks
alnag = pi_alnag.
MODIFY lt_pp04_cache
INDEX sy-tabix
TRANSPORTING arbpl ktext.
ENDIF.
ENDIF.
*ENDFORM. " read_last_pp04_operation_cache
*& Form read_routing
form read_routing.
data: begin of lt_mapl occurs 0,
plnnr like mapl-plnnr,
plnal like mapl-plnal,
end of lt_mapl,
l_arbpl like crhd-arbpl.
get all the rtg# and grp ctr# from MAPL
select plnnr plnal
into corresponding fields of table lt_mapl
from mapl
where matnr = v_matnr and
werks = itab_xcel-werks and
plnty = v_plnty and "Rate Routing
loekz = space. "with del flag = OFF
sort lt_mapl by plnal.
if not itab_xcel-verid is initial.
if the verid=0001 then use the 1st good rtg-grp# and grp-ctr#
if itab_xcel-verid = '0001'.
read table lt_mapl index 1.
v_plnnr = lt_mapl-plnnr.
v_plnal = lt_mapl-plnal.
else.
if the verid0001 then use the rtg-grp# and grp-ctr# of the routing
whose work center on the last PP04 operation matches the given verid
loop at lt_mapl.
clear l_arbpl.
get the work center from the last PP04 operation
perform read_wc_on_last_pp04 using lt_mapl-plnnr
lt_mapl-plnal
changing l_arbpl.
if itab_xcel-verid = l_arbpl.
v_plnnr = lt_mapl-plnnr.
v_plnal = lt_mapl-plnal.
exit.
endif.
endloop.
endif.
else.
do nothing
endif.
For version IDs that are other then '0000' or 'ZWIP' :--
if itab_xcel-verid NE '0000' and
itab_xcel-verid NE 'ZWIP'.
if routing group# or group counter was not determined, make the
valid-to date 99/99/9999 so that the BDC, on execution, errors out.
if v_plnnr is initial or
v_plnal is initial.
itab_xcel-bdatu = '99/99/9999'.
endif.
endif.
determine the routing group#
CLEAR lt_pp04_cache.
chk if its in the cache first, if not then get it from MAPL table
and put it in the cache
READ TABLE lt_pp04_cache WITH KEY matnr = pi_matnr
werks = pi_werks
alnag = pi_alnag.
IF sy-subrc = 0.
do nothing - lt_pp04_cache header line has rtg#
ELSE.
get the routing group # from MAPL
put it in the cache internal table
IF NOT l_mapl_plnnr IS INITIAL.
lt_pp04_cache-matnr = pi_matnr.
lt_pp04_cache-werks = pi_werks.
lt_pp04_cache-alnag = pi_alnag.
lt_pp04_cache-plnnr = l_mapl_plnnr.
APPEND lt_pp04_cache.
ENDIF.
ENDIF.
if the rtg# was determined AND
-- the work center was not determined yet AND
-- work center was really needed for this line in the input file
then
-- read the work center from last PP04 operation on the routing
-- update the cache accordingly
IF NOT lt_pp04_cache-plnnr IS INITIAL AND
lt_pp04_cache-arbpl IS INITIAL AND
( pi_verid IS INITIAL OR
pi_mdv01 IS INITIAL ).
read the last PP04 operation
CLEAR lt_plpo.
REFRESH lt_plpo.
SELECT vornr eobjty eobjid e~arbpl
INTO CORRESPONDING FIELDS OF TABLE lt_plpo
FROM plas AS b
INNER JOIN plpo AS c
ON bplnty = cplnty AND
bplnnr = cplnnr AND
bzaehl = czaehl
INNER JOIN crhd AS e
ON carbid = eobjid
WHERE b~plnty = v_plnty AND
b~plnnr = lt_pp04_cache-plnnr AND
b~plnal = lt_pp04_cache-alnag AND
c~loekz = space AND
c~steus = v_plpo_steus AND
e~objty = v_objty AND
e~werks = lt_pp04_cache-werks AND
e~verwe = v_verwe.
SORT lt_plpo BY vornr DESCENDING.
READ TABLE lt_plpo INDEX 1.
IF NOT lt_plpo-arbpl IS INITIAL.
lt_pp04_cache-arbpl = lt_plpo-arbpl.
read work center description
SELECT SINGLE ktext INTO lt_pp04_cache-ktext
FROM crtx WHERE objty = lt_plpo-objty AND
objid = lt_plpo-objid AND
spras = sy-langu.
the following read will get the index of the correct record to be
updated in the cache
READ TABLE lt_pp04_cache
WITH KEY matnr = pi_matnr
werks = pi_werks
alnag = pi_alnag.
MODIFY lt_pp04_cache
INDEX sy-tabix
TRANSPORTING arbpl ktext.
ENDIF.
ENDIF.
endform. " read_last_pp04_operation_cache
*& Form read_wc_on_last_pp04
form read_wc_on_last_pp04 using pi_plnnr
pi_plnal
changing pe_arbpl.
data: begin of lt_plpo occurs 0,
vornr like plpo-vornr,
objty like crhd-objty,
objid like crhd-objid,
arbpl like crhd-arbpl,
end of lt_plpo.
get all the PP04 operations for the given rtg# & grp-ctr#
select vornr eobjty eobjid e~arbpl
into corresponding fields of table lt_plpo
from plas as b
inner join plpo as c
on bplnty = cplnty and
bplnnr = cplnnr and
bzaehl = czaehl
inner join crhd as e
on carbid = eobjid
where b~plnty = v_plnty and "Rate Routing
b~plnnr = pi_plnnr and
b~plnal = pi_plnal and
c~loekz = space and "Oper Del Flag = OFF
c~steus = v_plpo_steus and "PP04
e~objty = v_objty. "WC Obj Type = 'A'
read the last operation
sort lt_plpo by vornr descending.
read table lt_plpo index 1.
pe_arbpl = lt_plpo-arbpl.
endform. " read_wc_on_last_pp04
Goto LSMW-> Select Direct Input method in 1st step. These are the standard programs for data transfer.
Otherwise goto SPRO->SAP Reference IMG-> Under this you'll find standard data transfer programs module wise.
Reward points,
Shakir -
Difference between Session method and Call transaction method
Hi,
Difference between Session method and Call transaction method in BDCHi,
SESSION method:
Is a standard procedure for transferring large amount of data into the R/3 system.
Data consistency is ensured because batch input uses all thje checks conducted on the normal screen.
It is a two step procedure:
1. Progarm: creates batch input session. This session is the data file that includes everything to begin the transaction.
2. Process session: Which then actually transfers the data to database table.
In this method an ABAP/4 program reads the external data that is to be entered in the SAP system and stores the data in a session.
A session stores the actions that are required to enter your data using normal SAP transactions i.e. data is transferred to session which inturn transfers data to database table. Session is an intermediate step between internal table and database table.
Data along with it's actions are stored in session. i.e. data for screen fields, to which screen it is passed, the program name behind it and how next screen is processed.
When the program has finished generating the session, u can run the session to execute the SAP transactions in it.
BDC_OPEN_GROUP
You create the session through program by BDC_OPEN_GROUP function.
1) User Name: User Name.
2) Group : Name of the session
3) Lock Date : The date when you want to process the session.
4) Keep : This parameter is passed as 'X' when you want to retain session even after processing it.
BDC_INSERT
Data is transferred to session by BDC_INSERT.
BDC_CLOSE_GROUP.
With this function the session will be closed.
CALL TRANSACTION method.
Syntax: call transaction <tr code> using <bdctab>
mode <A/N/E>
update <S/A>
messages into <internal table>.
<tr code> : transaction code
<bdctab> : Name of the BDC table
mode: mode in which you execute the transaction.
A : all screen mode ( all the screens of the transaction are displayed )
N : no screen mode ( no screen will be displayed when you execute the transaction )
E : error screen ( only those screens are displayed where in you have error record )
Update type:
S: synchronous update in which if you change data of one table then all the related tables gets updated and SY_SUBRC is returned for once and all.
A: asynchronous update in which if you change data of one table, the sy-subrc is returned and then updation of other affected tables takes place. So if system fails to update other tables still sy-subrc returned is zero.(that is when first table gets updated ).
messages: if you update database table, operation is either successful or unsuccessful. These messages are stored in internal table. This internal table structure is like BDCMSGCOLL.
TCODE: transaction code.
DYNAME: batch input module name.
DYNNUMB: batch input dyn no.
MSGTYP: batch input message type.
MSGSPRA: batch input language id of message.
MSGID: message id.
MSGV1 .MSGV5: message variables
For each entry which is updated in the database table message is available in BDCMSGCOLL.
Reward if useful
Regards
Srinu -
Hi,
I wanted to know the difference between what typical implementations of Transaction.rollback() and Transaction.setRollbackOnly().
I have used setRollbackOnly()? in distributed transaction scenarios. How is it different from rollback()?
Thanks
ShaileshI would really recommend posting this question in a forum where somebody might understand what you are talking about. This is the XML forum.
-
Is "SET TRANSACTION USE ROLLBACK SEGMENT" only a hint
I have two users, one makes some inserts in a table.
The other makes a select which visits many rows.
I have a big rollback-segment.
To ensure, both users use this rollback-segment I created a logon-trigger:
CREATE OR REPLACE TRIGGER a_logon AFTER LOGON
ON DATABASE
WHEN ( USER IN ( 'SCOTT', 'BOB' ) )
BEGIN
SET TRANSACTION USE ROLLBACK SEGMENT rbs_big;
END;
But I still get "snapshot to old" messages from the select, which contains the name off an other rollback-segment in the message.
The trigger really fires, i tested it by adding an insert-statement to a log-table.
What`s wrong ?The set transaction use rollback segment lasts only until you commit or rollback first time and all other transactions in that session will not be forced to that rbs anymore. Other possible solution could be that other users are accessing same tables / updating them so those sessions can't keep the read consistent image available anymore for your sessions.
-
Database session rollback.
How can I issue a database session rollback from within an ADF jpanel?
Here are a few things I tryied:
I used:
panelBinding.getOperationBinding("Rollback");
-->This does not seem to rollback anything.
panelBinding.releaseDataControl();
panelBinding.getApplication().getApplicationModule().getTransaction().rollback();
-->This two look like they do rollback and release all data everywhere, not just in the panel it was issued, so all my pages will have to bind again (re-query) which makes the app very slow.
This is supposed to be a read only app.
I guess what I am looking for is to possible issue a session rollback when exiting an ADF jpanel, without forcing re-binding, equerry of all my ADF views and ADF view links.
Or probably set a JOB parameter which would make the entire app read only and would never attempt update if any rows displayed were changed my mistake.
Your input is most appreciated.
Thanks.
Edited by: user2456231 on Dec 20, 2010 3:29 PM
Edited by: user2456231 on Dec 21, 2010 4:20 PMThanks for you response.
This is a read only app, all the object views are based on read only SQL, but because I have defined in the object view the field displayed to be always updatable so it can be highlighted, and copied into clipboard, so it would be easy to copy and paste stuff into email or other documents, sometime this copy and paste process causes a field to be modified accidentally, so I need to include a rollback statement every time an ADF jpanel is closed, just to clean up and rollback these type of situations.
You wrote:
“A rollback is on the transaction, which is held by the Application Module. If you only want to rollback partial changes then you need to first set a savepoint in ADF BC and recover to this savepoint”
I understand that and I do want to rollback every thing that the application module might have accidentally modified, but once I issue the rollback using the following:
panelBinding.getApplication().getApplicationModule().getTransaction().rollback();
This causes the app to rebind, meaning all my ADF object views and pages will have to bind again (re-query) which makes the app very slow to navigate. Is there any way to avoid this? Meaning rollback but do not re-bind, requery or refresh the rows already displayed?
Thanks. -
Transactional Session JMS Adapter
Hi,
i'm using a JMS sender and receiver adapter. Everything works but i can't understand if it'could be better to use a Transactional Session in Jms setting. I've found a lot of documentation about jms adapter configuration, but not so much information about Transactional Session field.
Could somebody explain me something more??
When can i use transactional session?
Thanks a lot.
Bye, bye..Hi,
The Transactional Session in JMS is used to persist the messages or may get roll back if in case of failure.
The JMS adapter (Java Message Service) enables you to connect messaging systems to the Integration Engine or the PCK. The messages will be processed in Queue i.e WebSphere MQ series, SonicMQ and others...
Suppose in case of failure of the connectivity the messages maintained in queue may lost. That would be serious problem if the queue is maintained with the messages having important data from production landscape.
If you enable a transactional JMS session, set the indicator. The processing of a message will be safe, a transactional session ends either with a COMMIT, or in the case of an error, with a ROLLBACK. So there will not be any chance of loss of the messages in queue.
If the session is not transactional, there can be duplicates or lost messages.
I hope now it will pretty clear to you the purpose of Transactional session.
Thanks
Swarup -
Hi,
If I use transacted session in MDB with container managed transaction, dose the
weblogic ignore the transacted setting or start in it's own transaction. I looked
the JMS Tutorial from Sun, the J2EE server just ignore the transacted setting,
treated it as non-transacted session.
Thanks
Thanks, Greg. I created another XAQCF in MQ JMSADMIN, but still did not help. The
strange part is when this exception happens, in the Event Viewer there is a Message:
An internal Websphere MQ Error has occurred'. In the Trace Log of MQ, the Major
Error Code reported is arcE_XAER_PROTO.
Has anyone encountered this error? The same code works fine when enlist an XAQCF
defined in Weblogic and PUT into a Weblogic JMS Queue instead within the same
XA Transaction. I am attaching the stack trace to this message, just in case,
someone has useful pointers to help me. May be this is MQ Specific though I made
sure I have the latest FixPack for MQ installed.
Thanks,
Sridhar
"Greg Brail" <[email protected]> wrote:
>Yeah. This comes up from time to time. MQ is upset because it wants to
>be
>enlisted in the JTA transaction, but JTA is not enlisting it because
>it
>thinks it's already enlisted. It thinks it's already enlisted because
>the
>same MQ connection factory was used for the MDB input queue, even though
>it's a different JMS connection and session.
>
>You can avoid this by creating another "XAQCF" object in the MQ JNDI
>space
>and giving it a different name. If you do that -- essentially use different
>connection factories for the MDB's input and output queues -- then this
>will
>work.
>
>Also, the transaction enlistement code in 8.1 that supports the
>"resource-ref" feature avoids this problem.
>
> greg
>
>"Sridhar Krishnaswamy" <[email protected]> wrote in message
>news:[email protected]...
>>
>> Hi Greg:
>> I assume you meant to getXAResource() from an Object of type
>XAQueueSession. Here
>> is the code I tried within the onMessage() method of the MDB:
>>
>> XAQueueConnectionFactory factory = (XAQueueConnectionFactory)
>ctx.lookup("XAQCF")
>> ;
>> XAConnection connection = factory.createXAQueueConnection() ;
>>
>> XAQueueSession mqSession = connection.createXAQueueSession() ;
>> XAResource mqResource = mqSession.getXAResource() ;
>> Transaction tran = TxHelper.getTransaction() ;
>> tran.enlist(mqResource) ;
>>
>> //Then I was going to get the QueueSession Object from XAQueueSession,
>obtain
>> the Queue
>> //Object from JNDI, create the Sender
>> //and call the send. But I commented out these calls. Even then, after
>the
>onMessage
>> Method
>> // completes, I get the following error:
>>
>> javax.transaction.SystemException: start() failed on resource
>'com.ibm.mq.MQXAResource':
>> XAER_PROT : Routine was invoked in an improper context
>> javax.transaction.xa.XAException: XA Operation failed. see errorcode
>(which I
>> am assuming is XAER_PROT).
>>
>> Any idea, what I am doing wrong?
>>
>>
>>
>>
>> "Greg Brail" <[email protected]> wrote:
>> >In 7.0, you can do your MQ "put" inside the same JTA transaction that
>> >was
>> >used to receive the message for the MDB, but you have to do the
>transaction
>> >enlistment yourself. Basically, you have to use the class
>> >weblogic.transaction.TxHelper class to get a reference to the current
>> >transaction, then call "enlistResource" on the transaction using the
>> >JTA
>> >"XAResource" that you get from the MQ JMS "Session" object. I'm sure
>> >we've
>> >posted the code in this newsgroup before, but I don't know where,
>so
>> >it
>> >would look something like:
>> >
>> >// First, get the MQ QueueSession object you're going to use to send
>> >the
>> >message
>> >QueueSession mqSession = mqConnection.createQueueSession(false, 0);
>> >XAResource mqResource = mqSession.getXAResource();
>> >weblogic.transaction.Transaction tran =
>> >weblogic.transaction.TxHelper.getTransaction();
>> >tran.enlistResource(mqResource);
>> >// Now send your message
>> >
>> >In 8.1, this will still work, but it's not necessary. If you register
>> >the MQ
>> >XA connection factory as a "resource-reference" in your EJB deployment
>> >descriptors and look it up using java:comp/env the way the documentation
>> >link way below describes, then this transaction enlistment happens
>> >automatically. This only happens when you use the "resource-reference"
>> >feature (which means that old code will still work if it does NOT
>use
>> >this
>> >feature), and it's only in 8.1.
>> >
>> > greg
>> >
>> >"Sridhar Krishnaswamy" <[email protected]> wrote in
>message
>> >news:[email protected]...
>> >>
>> >> Hi Greg:
>> >> Is the Statement
>> >>
>> >> 'But in this case, you don't get a "non-transactional" session,
>but
>> >actually a
>> >> session that participates in the current JTA transaction for the
>thread
>> >where
>> >> your EJB is running'
>> >>
>> >> also true in the case of an MDB running in Weblogic 7.0 (Container
>> >Managed
>> >Transactions)
>> >> driven by an XAQCF and a Foreign JMS Provider such as MQSeries?
>In
>> >other
>> >words,
>> >> if I want the MDB to PUT the Message into an MQSeries Queue, can
>the
>> >PUT
>> >be invoked
>> >> under the Context of the Same XA Transaction? My understanding is
>that
>> >WebLogic
>> >> 7.0 doesn't support send
>> >> messages out of an MDB within the same XA transaction if the MDB
>is
>> >> XA-driven by a foreign JMS provider. Please let me know if this
>is
>> >false.
>> >If true,
>> >> does Weblogic 8.1 also have this restriction?
>> >>
>> >> Thanks,
>> >> Sridhar Krishnaswamy.
>> >>
>> >> "Greg Brail" <[email protected]> wrote:
>> >> >What do you mean by "use transacted session in MDB?" Are you creating
>> >> >a new
>> >> >session inside your MDB, or do you mean something else?
>> >> >
>> >> >The only Sun thing I can think of is in code that looks like this:
>> >> >
>> >> >InitialContext ctx = new InitialContext();
>> >> >QueueConnectionFactory qcf = ctx.lookup("java:comp/env/jms/QCF");
>> >> >Queue queue = ctx.lookup("java:comp/env/jms/Queue");
>> >> >QueueConnection connection = qcf.createQueueConnection();
>> >> >// Create "transacted" session:
>> >> >QueueSession session = connection.createQueueSession(true, 0);
>> >> >QueueSender sender = session.createQueueSender(queue);
>> >> >TextMessage message = session.createTextMessage("Hello, world");
>> >> >sender.send(message);
>> >> >connection.close();
>> >> >
>> >> >If you do this, and exactly this, inside an EJB, including the
>use
>> >of
>> >> >"java:comp/env/jms", in WebLogic Server 8.1, then we do indeed
>ignore
>> >> >the
>> >> >"transacted" flag when you create the session, just like Sun says
>> >we
>> >> >should
>> >> >in the EJB and J2EE specs. But in this case, you don't get a
>> >> >"non-transactional" session, but actually a session that participates
>> >> >in the
>> >> >current JTA transaction for the thread where your EJB is running.
>> >> >
>> >> >The idea is that if you are working inside an EJB, you don't use
>> >transacted
>> >> >sessions -- you use the transaction control given to you by the
>EJB
>> >> >container, including the UserTransaction interface and/or the various
>> >> >container-managed transaction flags, rather than the JMS "transacted
>> >> >session".
>> >> >
>> >> >You can find more information here:
>> >> >
>> >> >http://e-docs.bea.com/wls/docs81/jms/j2ee_components.html
>> >> >
>> >> > greg
>> >> >
>> >> >"Jen" <[email protected]> wrote in message
>> >> >news:[email protected]...
>> >> >>
>> >> >> Hi,
>> >> >>
>> >> >> If I use transacted session in MDB with container managed
>transaction,
>> >> >dose the
>> >> >> weblogic ignore the transacted setting or start in it's own
>> >transaction.
>> >> >I
>> >> >looked
>> >> >> the JMS Tutorial from Sun, the J2EE server just ignore the
>transacted
>> >> >setting,
>> >> >> treated it as non-transacted session.
>> >> >> Thanks
>> >> >
>> >> >
>> >>
>> >
>> >
>>
>
>
[eRRORS.txt]
-
NON-transactional session bean access entity bean
We are currently profiling our product using Borland OptmizeIt tool, and we
found some interesting issues. Due to our design, we have many session beans which
are non transactional, and these session beans will access entity beans to do
the reading operations, such as getWeight, getRate, since it's read only, there
is no need to do transaction commit stuff which really takes time, this could
be seen through the profile. I know weblogic support readonly entity bean, but
it seems that it only has benefit on ejbLoad call, my test program shows that
weblogic still creates local transaction even I specified it as transaction not
supported, and Transaction.commit() will always be called in postInvoke(), from
the profile, we got that for a single method call, such as getRate(), 80% time
spent on postInvoke(), any suggestion on this? BTW, most of our entity beans are
using Exclusive lock, that's the reason that we use non-transactional session
bean to avoid dead lock problem.
ThanksSlava,
Thanks for the link, actually I read it before, and following is what I extracted
it from the doc:
<weblogic-doc>
Do not set db-is-shared to "false" if you set the entity bean's concurrency
strategy to the "Database" option. If you do, WebLogic Server will ignore the
db-is-shared setting.
</weblogic-doc>
Thanks
"Slava Imeshev" <[email protected]> wrote:
Hi Jinsong,
You may want to read this to get more detailed explanation
on db-is-shared (cache-between-transactions for 7.0):
http://e-docs.bea.com/wls/docs61/ejb/EJB_environment.html#1127563
Let me know if you have any questions.
Regards,
Slava Imeshev
"Jinsong HU" <[email protected]> wrote in message
news:[email protected]...
Thanks.
But it's still not clear to me in db-is-shared setting, if I specifiedentity
lock as database lock, I assumed db-is-shared is useless, because foreach
new
transaction, entity bean will reload data anyway. Correct me if I amwrong.
Jinsong
"Slava Imeshev" <[email protected]> wrote:
Jinsong,
See my answers inline.
"Jinsong Hu" <[email protected]> wrote in message
news:[email protected]...
Hi Slava,
Thanks for your reply, actually, I agree with you, we need to
review
our db
schema and seperate business logic to avoid db lock. I can not say,guys,
we need
to change this and that, since it's a big application and developedsince
EJB1.0
spec, I think they are afraid to do such a big change.Total rewrite is the worst thing that can happen to an app. The
better aproach would be identifying the most critical piece and
make a surgery on it.
Following are questions in my mind:
(1) I think there should be many companies using weblogic serverto
develop
large enterprise applications, I am just wondering what's the maintransaction/lock
mechanism that is used? Transional session / database lock,
db-is-shared
entity
I can't say for the whole community, as for my experience the standard
usage patthern is session fasades calling Entity EJBs while having
Required TX attribute plus plain transacted JDBC calls for bulk
reads or inserts.
is the dominant one? It seems that if you speficy database lock,
the
db-is-shared
should be true, right?Basically it's not true. One will need db-is-shared only if thereare
changes
to the database done from outside of the app server.
(2) For RO bean, if I specify read-idle-timeout to 0, it shouldonly
load
once at the first use time, right?I assume read-timeout-seconds was meant. That's right, but if
an application constantly reads new RO data, RO beans will be
constantly dropped from cache and new ones will be loaded.
You may want to looks at server console to see if there's a lot
of passivation for RO beans.
(3) For clustering part, have anyone use it in real enterpriseapplication?
My concern, since database lock is the only way to choose, how aboutthe
affect
of ejbLoad to performance, since most transactions are short live,if high
volume
transactions are in processing, I am just scared to death about
the
ejbLoad overhead.
ejbLoad is a part of bean's lifecycle, how would you be scared ofit?
If ejbLoads take too much time, it could be a good idea to profile
used SQLs. Right index optimization can make huge difference.
Also you may want cosider using CMP beans to let weblogic
take care about load optimization.
(4) If using Optimization lock, all the ejbStore need to do
version
check
or timestamp check, right? How about this overhead?As for optimistic concurrency, it performs quite well as you can
use lighter isolation levels.
HTH,
Slava Imeshev
"Jinsong Hu" <[email protected]> wrote in message
news:[email protected]...
We are using Exclusive Lock for entity bean, because of we do
not
want
to
load
data in each new transaction. If we use Database lock, that means
we
dedicate
data access calls to database, if database deadlock happens,
it's
hard
to
detect,
while using Exclusive lock, we could detect this dead lock in
container
level.
The problem is, using Exclusive concurrency mode you serialize
access to data represented by the bean. This aproach has negative
effect on ablity of application to process concurrent requests.As
a
result the app may have performance problems under load.
Actually, at the beginnning, we did use database lock and usingtransactional
The fact that you had database deadlocking issues tells that
application logic / database schema may need some review.
Normally to avoid deadlocking it's good to group database
operations mixing in updattes and inserts into one place so
that db locking sequence is not spreaded in time. Moving to
forced serialized data access just hides design/implementation
problems.
session bean, but the database dead lock and frequent ejbLoad
really
kill
us,
so we decided to move to use Exclusive lock and to avoid dead
lock,
we
change
some session bean to non-transactional.Making session beans non-transactions makes container
creating short-living transactions for each call to entity bean
methods. It's a costly process and it puts additional load to
both container and database.
We could use ReadOnly lock for some entity beans, but since weblogicserver will
always create local transaction for entity bean, and we found
transaction
commit
is expensive, I am arguing why do we need create container leveltransaction for
read only bean.First, read-only beans still need to load data. Also, you may seeRO
beans
contanly loading data if db-is-shared set to true. Other reason
can
be
that
RO semantics is not applicable the data presented by RO bean (forinstance,
you have a reporting engine that constantly produces "RO" data,
while
application-consumer of that data retrieves only new data and neverasks
for "old" data). RO beans are good when there is a relatively stable
data
accessed repeatedly for read only access.
You may want to tell us more about your app, we may be of help.
Regards,
Slava Imeshev
I will post the performance data, let's see how costful
transaction.commit
is.
"Cameron Purdy" <[email protected]> wrote:
We are currently profiling our product using Borland
OptmizeIt
tool,
and we
found some interesting issues. Due to our design, we have
many
session
beans which
are non transactional, and these session beans will access
entity
beans
to
do
the reading operations, such as getWeight, getRate, since
it's
read
only,
there
is no need to do transaction commit stuff which really takes
time,
this
could
be seen through the profile. I know weblogic support readonly
entity
bean,
but
it seems that it only has benefit on ejbLoad call, my test
program
shows
that
weblogic still creates local transaction even I specified
it
as
transaction not
supported, and Transaction.commit() will always be called
in
postInvoke(),
from
the profile, we got that for a single method call, such as
getRate(),
80%
time
spent on postInvoke(), any suggestion on this? BTW, most of
our
entity
beans are
using Exclusive lock, that's the reason that we use
non-transactional
session
bean to avoid dead lock problem.I am worried that you have made some decisions based on an improper
understand of what WebLogic is doing.
First, you say "non transactional", but from your description
you
should
have those marked as tx REQUIRED to avoid multiple transactions
(since
non-transactional just means that the database operation becomesits
own
little transaction).
Second, you say you are using exclusive lock, which you shouldonly
use
if
you are absolutely sure that you need it, (and note that it
does
not
work in
a cluster).
Peace,
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com/coherence.jsp
Tangosol Coherence: Clustered Replicated Cache for Weblogic
"Jinsong Hu" <[email protected]> wrote in message
news:[email protected]...
> -
Not be able to obtain a transacted session within stateless session bean
I need some assistance on creating a transacted session. For some reason while within a stateless session bean, I am unable to create a transacted session even though I'm specifying to create the transacted queue session. Can anyone provide any assistance to me on this? It would be much appreciated.
Here is the code snippets involved with the problem:
Code snipet from ejb-jar.xml:
<session>
<display-name>Initial Request</display-name>
<ejb-name>InitialRequestBean</ejb-name>
<ejb-class>com.raytheon.rds.jms.InitialRequestBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
Code from stateless session bean:
static Logger logger;
private QueueConnectionFactory connectionFactory;
private SessionContext sc;
private Queue requestQueue;
public String processRequest(String msgBody)
logger.log(Level.INFO, "In processRequest(String).", msgBody);
QueueConnection con = null;
QueueSession session = null;
QueueSender sender = null;
TextMessage message = null;
String messageID = null;
QueueReceiver receiver = null;
TemporaryQueue replyQueue = null;
boolean transacted = false;
try
//Create the infrastructure (ie. The connection & the session)
logger.log(Level.FINE, "Creating connection");
con = connectionFactory.createQueueConnection();
logger.log(Level.FINE, "Creating session");
session = con.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
//Note: This line above was changed in all possible permutation and still didn't work such as using Session.SESSION_TRANSACTED
transacted = session.getTransacted();
logger.log(Level.FINE, "Is session transacted? : " + transacted);
//Note: This line above is constantly saying false
//Now first, setup the temporary reply queue and its listener
replyQueue = session.createTemporaryQueue();
logger.log(Level.FINE, "Creating receiver/consumer");
receiver = session.createReceiver(replyQueue);
con.start();
//Now create the requestor that will make the request message and put it on the request queue
logger.log(Level.FINE, "Creating Requestor/Producer");
sender = session.createSender(requestQueue);
//Now create the message and make sure that you put the "JMSReplyTo" property to the temporary response queue we just created
message = session.createTextMessage();
message.setJMSReplyTo(replyQueue);
logger.log(Level.FINE, "Created message: " + message.getJMSMessageID());
//Now add the actual info you want to send
message.setText(msgBody);
//Now send the message
logger.log(Level.INFO, "Sending message: " + message.getText());
sender.send(message);
//Now wait until we get a response
logger.log(Level.FINE, "Waiting for the response message");
Message responseMsg = receiver.receive(20000); //Toggle the "0" to specify timeout in millisectionds
//Process the message
logger.log(Level.FINE, "Processing the response message");
if(null != responseMsg)
logger.log(Level.FINE, "responseMsg is : " + responseMsg.toString());
messageID = processMessage(responseMsg);
logger.log(Level.FINE, "Response is : " + messageID);
//close the connection
logger.log(Level.FINE, "Stopping the connection");
con.stop();
catch (Throwable t)
// JMSException could be thrown
logger.log(Level.SEVERE, "Exception Thrown in sendRequest: ", t);
sc.setRollbackOnly();
finally
//Close the sender
if (sender != null)
try
logger.log(Level.FINE, "Closing the sender");
sender.close();
catch (JMSException e)
logger.log(Level.WARNING, "JMSException Thrown when trying to close the sender to the request queue: ", e);
else
logger.log(Level.FINE, "Sender is already closed.");
//Close the receiver
if (receiver != null)
try
logger.log(Level.FINE, "Closing the receiver");
receiver.close();
catch (JMSException e)
logger.log(Level.WARNING, "JMSException Thrown when trying to close the receiver to the request queue: ", e);
else
logger.log(Level.FINE, "Receiver is already closed.");
//Close the session
if (session != null)
try
logger.log(Level.FINE, "Closing the session");
session.close();
catch (JMSException e)
logger.log(Level.WARNING, "JMSException Thrown when trying to close the session to the request queue: ", e);
else
logger.log(Level.FINE, "Session is already closed.");
//Close the connection
if (con != null)
try
logger.log(Level.FINE, "Closing the connection");
con.close();
catch (JMSException e)
logger.log(Level.WARNING, "JMSException Thrown when trying to close the connection to the reply queue: ", e);
else
logger.log(Level.FINE, "Connection is already closed.");
return messageID;
}I found the answer through lots of painful searching.
http://blogs.sun.com/fkieviet/entry/request_reply_from_an_ejb
This weblog from Frank Kieviet from a sun blog explains what's happening behind the scenes.
Then I proceeded to create a Bean-Managed Transaction out of my EJB, which is using EJB 3.0. This requires the tag:
@TransactionManagement(value= TransactionManagementType.BEAN)
Note: I got this information from http://download.oracle.com/docs/cd/B31017_01/web.1013/b28221/servtran001.htm#BAJIBAFF
Then I just added the code specified in Frank's blog and everything is working now. The main portion of the code looks like this now:
//begin the user transaction
ctx.getUserTransaction().begin();
//Create the infrastructure (ie. The connection & the session)
logger.log(Level.FINE, "Creating connection");
con = connectionFactory.createQueueConnection();
//Create the session
logger.log(Level.FINE, "Creating session");
session = con.createQueueSession(false, Session.SESSION_TRANSACTED);
transacted = session.getTransacted();
logger.log(Level.FINE, "Is session transacted? : " + transacted);
//Now create the sender that will make the request message and put it on the request queue
logger.log(Level.FINE, "Creating Sender");
sender = session.createSender(requestQueue);
//Now create the message
message = session.createTextMessage();
//Now add the actual info you want to send
message.setText(msgBody);
logger.log(Level.FINE, "Created message: " + message.getJMSMessageID());
//Now first, setup the temporary reply queue and its listener
replyQueue = session.createTemporaryQueue();
if(null != replyQueue)
logger.log(Level.FINE, "Created temporary queue: " + replyQueue.getQueueName());
else
logger.log(Level.FINE, "Temporary Queue could not be created.");
//make sure that you put the "JMSReplyTo" property to the temporary response queue we just created
message.setJMSReplyTo(replyQueue);
//Now send the message
logger.log(Level.INFO, "Sending message: " + message.getText());
sender.send(message);
//Now start the connection
logger.log(Level.FINE, "Starting the connection");
con.start();
//commit the changes
ctx.getUserTransaction().commit();
ctx.getUserTransaction().begin();
//Create the receiver
logger.log(Level.FINE, "Creating Receiver");
receiver = session.createReceiver(replyQueue);
//Now wait until we get a response
logger.log(Level.FINE, "Waiting for the response message");
Message responseMsg = receiver.receive(20000); //Toggle the "0" to specify timeout in millisectionds
//Process the message
logger.log(Level.FINE, "Processing the response message");
if(null != responseMsg)
logger.log(Level.FINE, "responseMsg is : " + responseMsg.toString());
else
logger.log(Level.FINE, "No response came back.");
messageID = processMessage(responseMsg);
logger.log(Level.FINE, "Response is : " + messageID);
logger.log(Level.FINE, "Transaction is complete");
//commit the changes
ctx.getUserTransaction().commit(); -
How to get transacted session in direct mode with jmsra adapter
Hi,
I use MQ 4.4u1 release with GF in EMBEDDED mode. I configured several connection factories with NoTransaction/LocalTransaction/XATransaction support. In my app I get a connection factory from JNDI tree, create connection/session/producer and send several messages to queue. Everything works fine when I don't use transactions. But, when I want to send messages in one transaction, the connection always provided to me non-transacted session. The session created via
Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
request. I check the session transacted state and acknowledge mode right after i get it:
log.fine("Session: " + session + "; transacted: " + session.getTransacted() + "; ackMode: " + session.getAcknowledgeMode());
The log shows me that the session is not transacted and ackMode is 0 (DUPS_OK_ACKNOWLEDGE). If I try to commit the session after messages were sent I get the correct exception:
javax.jms.IllegalStateException: MQJMSRA_DS4001: commit():Illegal for a non-transacted Session:sessionId=3361979872663370240
Does anyone know how to get transactional session in direct mode?
Thanks, Denis.I mentioned LOCAL because I misread your post and thought you were suggesting that LOCAL mode behaved differently.
If you want to send messages in a transaction from within a Servlet then I think you're expected to use a UserTransaction: Here's an example that worked for me:
Connection connection = outboundConnectionFactory.createConnection();
Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
userTransaction.begin();
MessageProducer producer = session.createProducer(outboundQueue);
int numberOfMessages = 10;
for (int i = 0; i<numberOfMessages; i++) {
Message message = session.createTextMessage("Hello world");
producer.send(message);
userTransaction.commit();
connection.close();I obtained the UserTransaction with this resource declaration:
@Resource(name = "java:comp/UserTransaction")
private UserTransaction userTransaction;The EJB spec explicitly states that local transactions aren't supported in EJBs; I haven't found such an explicit statement for Servlets but suspect that JMSRA is taking the same approach.
As for imq.jmsra.direct.disableCM property - this appears to disable connection pooling and from your post changes other behaviour as well. How did you find out about it (other than by examining the code)? As far as I can see this is not a documented feature and is not necessarily tested or supported. -
Set Transaction Use Rollback segment
Hi everybody. Does It make sense issue a "set transaction use rollback" for a single query that do not update, insert or delete. The trouble is that I get e "SnapShot too Old" for a query that just do a query.
Thanks!No, If you are not making any modifications then you do not generate rollback (or even a transaction to my knowledge). The SNAPSHOT TOO OLD is because a different session has run through the rollback for the read consistent view you need (either because someone made changes to a table you are reading or from delayed block cleanout). Delayed block cleanout is a pretty complicated scenario so I'll leave it to the Oracle documentation to explain that. Just be aware that even if nobody has made changes to the table since you started your query you can still get SNAPSHOT TOO OLD. Thankfully, 9i helps elleviate this somewhat with the introduction of UNDO TABLESPACES.
Richard -
Rollback and Scheduling in Database?
If we use the Timestamp Ordering for concurrency control in following scheduling:
http://oi59.tinypic.com/260361k.jpg
My note says T2,T3,T5 is Run and T4,T5 is Rollback. I think it's false. any expert could help us? (i.e, in this schedule which of the Transaction Rollback and which one Is Done?ISolation Level is not defined. would you please a default setting and consider more hint for me? why some rollback in this senario ?
default is read committed isolation. you are not helping us and yourself by not posting the details.
please post actual sql statements.. you can replace actual table names/column names to dummy names...
in forums, people(answerers) already do some sort of half guesses to interpret on question - on what might be issue(s). you can help us and yourself by providing more details and sql statements...
Hope it Helps!! -
How to combine Session Facade and Transfer object?
Hello All!
I'm working on an enterprise application. Presentation layer is a stand alone client, business logic is build on the Glassfish v2.1 and MySQL is used as a database. The client is connection to the GlassFishj server remotely using EJBs.
I have problems with business logic architecture.
Here is the brief description of backend application architecture design:
1. Session Facade pattern is used to simplify the client and application server interface and to provide application layers between backend (http://java.sun.com/blueprints/corej2eepatterns/Patterns/SessionFacade.html).
2.Transfer Object pattern to define update transfer objects strategy in order to decrease network overhead during client and application server interactions and to provide version control for objects. Transfer objects are designed as simple java business serializable objects. (http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html)
3. Originally the backend application consisted of three modules: users, storage and orders, but at the end I have decided to divide my application into the following parts - assortments, map, menu, orders, transactions, users.
4. All MySQL database transactions are via JDBC using procedures. No use of entity beans.
Questions:
1. I have some doubts about using Session Facade and Transfer object patterns at the same time. At first I'd mike to cite the definitions of the patters from the SUN official web site.
* Use a session bean as a facade to encapsulate the complexity of interactions between the business objects participating in a workflow. The Session Facade manages the business objects, and provides a uniform coarse-grained service access layer to clients.
* Use a Transfer Object to encapsulate the business data. A single method call is used to send and retrieve the Transfer Object. When the client requests the enterprise bean for the business data, the enterprise bean can construct the Transfer Object, populate it with its attribute values, and pass it by value to the client.
* So, if I use Transfer Object along with Session Facade, it makes some difficulties with object version control, because I 2 or
3 transfer objects controls with the 1 bean class. The best option for Transfer object Pattern is that each transfer object should have its own bean class to provide ability of object's version control. In the case it can bring the network overhead because of frequent remote calls caused by the large number of the bean classes.
* So, should I use the both patterns? If yes, how to manage the interaction the patterns. If no, which one to use.
2. E.g. I have a huge list of the Order objects and each Order object consists of other complicated objects. So, would I have trouble to transfer that list over network? If yes, how to manage it.
Thank you!
AstghikAstghik wrote:
Hello All!
I'm working on an enterprise application. Presentation layer is a stand alone client, business logic is build on the Glassfish v2.1 and MySQL is used as a database. The client is connection to the GlassFishj server remotely using EJBs.
I have problems with business logic architecture.
Here is the brief description of backend application architecture design:
1. Session Facade pattern is used to simplify the client and application server interface and to provide application layers between backend (http://java.sun.com/blueprints/corej2eepatterns/Patterns/SessionFacade.html).
I would simply recommend establishing a service tier. Your services should be stateless. You can go the extra mile and have a session facade, but in the majority of cases, coding to an interface for your service accomplishes the same goals.
2.Transfer Object pattern to define update transfer objects strategy in order to decrease network overhead during client and application server interactions and to provide version control for objects. Transfer objects are designed as simple java business serializable objects. (http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html)
The idea of the transfer object is very similar to the Command pattern. I think if you investigate that pattern, it will be more obvious. The transfer object reduces network latency by consolidating all the parameters into an object, ideally, this also consolidates multiple method calls. If you combine a transfer object (or command object) with a service tier, you get the best of both worlds. The service can delegate calls to helper objects (or other services or components) using the data in the transfer / command object.
3. Originally the backend application consisted of three modules: users, storage and orders, but at the end I have decided to divide my application into the following parts - assortments, map, menu, orders, transactions, users.
The is your domain. It will vary from application to application. The principles above are more general (e.g., patterns and architectural tiers) and should apply to most domains. However, your actual use case may require something different.
4. All MySQL database transactions are via JDBC using procedures. No use of entity beans.
Consider using something like iBatis or Spring's JDBC templating to make your life easier with JDBC.
Questions:
1. I have some doubts about using Session Facade and Transfer object patterns at the same time. At first I'd mike to cite the definitions of the patters from the SUN official web site.
* Use a session bean as a facade to encapsulate the complexity of interactions between the business objects participating in a workflow. The Session Facade manages the business objects, and provides a uniform coarse-grained service access layer to clients.
* Use a Transfer Object to encapsulate the business data. A single method call is used to send and retrieve the Transfer Object. When the client requests the enterprise bean for the business data, the enterprise bean can construct the Transfer Object, populate it with its attribute values, and pass it by value to the client.
* So, if I use Transfer Object along with Session Facade, it makes some difficulties with object version control, because I 2 or
3 transfer objects controls with the 1 bean class. The best option for Transfer object Pattern is that each transfer object should have its own bean class to provide ability of object's version control. In the case it can bring the network overhead because of frequent remote calls caused by the large number of the bean classes.
* So, should I use the both patterns? If yes, how to manage the interaction the patterns. If no, which one to use.
Versioning is a separate issue. Generally, the more coarsely grained your transfer / command object is, the more changes are likely to impact dependent objects.
Your command or transfer object does not have to be a vanilla JavaBean, where you are basically creating a bean that has data from other objects. You can simply use your command / transfer object to encapsulate already existing domain objects. I see no need to map to a JavaBean with what you have described.
Generally, a method signature should be understandable. This means that many times it is better to pass the method, say, two coarsely grained objects than a signature with a dozen primitives. There are no hard and fast rules here. If you find a method signature getting large, consider a transfer / command object. If you want one service to delegate calls to a number of other services, you can also create a transfer / command object to furnish the controlling service with the data it needs to invoke the dependent services.
2. E.g. I have a huge list of the Order objects and each Order object consists of other complicated objects. So, would I have trouble to transfer that list over network? If yes, how to manage it.
This is a large, open-ended question. If you are going to display it to a user on a screen, I do not see how you avoid a network transfer with the data. The general answer is to not pass the data itself but rather a token (such as a primary key, or a primary key and a start and stop range such as you see on a Google search result). You do want to limit the data over the network, but this comes at a cost. Usually, the database will receive additional load. Once that becomes unacceptable, you might start putting things into session. Then you worry about memory concerns, etc. There is no silver bullet to the problem. It depends on what issues you are trying to address and what trade-offs are acceptable in your environment.
Thank you!
AstghikBest of luck.
- Saish
Maybe you are looking for
-
My Apple iPad 3 is less than 6 months old - purchased in March of 2012. I believe it already needs a new battery. It will not hold a charge for very long andvs very slow in starting up a carge when I plug it in. Please advise - it is very annoying
-
Is it possible to rotate a PDF when exporting from Indesign?
Is it possible to set a rotaton in the export PDF window of Indesign? I see I can do this in the print menu, but I don't want to export my PDFs this way.
-
Passing Array to Another Method
Hello, I created a program with an array in one of the methods. I have been trying to figure out how to correctly pass the array to another method in the same class. I know my problem is in my method delcaration statements. Could someone please show
-
Safari plays only some videos. Heaps of plugins
Youtube videos work fine, but at this site: http://preview.play.viostream.com/?play=a0f658df-16ee-4958-82bc-53b9ffd08a93&set play=no the screen just says missing plug-in Whe I left click the missing plug-in words the following message comes up: I hav
-
Confusion using Thread.sleep() method
I tried it in this program class NewThread implements Runnable { String name; // name of thread Thread t; NewThread(String threadname) { name = threadname; t = new Thread(this, name); System.out.println("New thread: " + t); t.st