Discussion:
Problem with a finder within a transaction
(too old to reply)
l***@knuerr.com
2006-11-13 17:14:00 UTC
Permalink
Hi,

I have created a MQ Controller Command, which create new user based on a MQ Message.
In order to achieve that I have used UserRegistrationAddCmd.
After that I have to update some information into the self-address.
And here comes my problem - the following finder doesn't work.

address = address.findSelfAddressByMember(mIdLong);

Were the mIdLong is the MemberID of the created customer. Theoritical it schould work although the commit from this transaction will be happened in the end of the command.

Could you say me - where I am wrong?

Thank you very much in advance!

lachezar

uab = new UserAccessBean("G");
uab.commitCopyHelper();
userId = uab.getUserId();

commandContext.changeStore(Integer.valueOf(storeId));
commandContext.setStoreId(Integer.valueOf(storeId));
commandContext.setUserId(Long.valueOf(userId));

requestProperties.put("logonPassword", CICPWD2_CP_Password_2);
requestProperties.put("logonPasswordVerify", CICPWD2_CP_Password_2);
requestProperties.put("logonId",CICNUM_Customer_Number + CICLOG_CP_Logon);
requestProperties.put("firstName", CICFNANE_CP_First_Name);
requestProperties.put("lastName", CICLNME_CP_Last_Name);
requestProperties.put("email1", CICMAIL_CP_Mail);
requestProperties.put("phone1", CICTEL_CP_Tel);
requestProperties.put("storeId", storeId);
requestProperties.put("preferredLanguage", langId);
requestProperties.put("URL", "URL=/webapp/wcs/stores/servlet/");

UserRegistrationAddCmd userRegAddCmd =
(UserRegistrationAddCmd) CommandFactory.createCommand(
UserRegistrationAddCmd.NAME, getStoreId());

userRegAddCmd.setCommandContext(commandContext);
userRegAddCmd.setRequestProperties(requestProperties);
userRegAddCmd.execute();

uab.refreshCopyHelper();
String mId = uab.getMemberId();
Long mIdLong = Long.valueOf(uab.getUserId());
try {
address = address.findSelfAddressByMember(mIdLong);
} catch (Exception e) {
e.printStackTrace();
throw new ECSystemException(
ECMessage._ERR_REMOTE_EXCEPTION,
"extCustomerRegistrationCmdImpl",
"performExecute");
}
address.setFax1(CICFAX_CP_Fax);
address.commitCopyHelper();
geo
2006-11-13 20:03:47 UTC
Permalink
You could do this with a pushdown query doing a find by ... with UR, since
you are in the same context that will find the uncommitted row existing from
the UserRegistration add. Another simple way to achieve the same with
minimal rework is to do command chaining. Complete the first portion of
the command that does the UserRegistrationAdd and forward to the command
that does the further update. Odd though, to my recollection from the
UserRegistrationAdd you can pull the self address directly from the
context.

Regards,
geo
Post by l***@knuerr.com
Hi,
I have created a MQ Controller Command, which create new user based on a MQ Message.
In order to achieve that I have used UserRegistrationAddCmd.
After that I have to update some information into the self-address.
And here comes my problem - the following finder doesn't work.
address = address.findSelfAddressByMember(mIdLong);
Were the mIdLong is the MemberID of the created customer. Theoritical it
schould work although the commit from this transaction will be happened in
the end of the command.
Could you say me - where I am wrong?
Thank you very much in advance!
lachezar
uab = new UserAccessBean("G");
uab.commitCopyHelper();
userId = uab.getUserId();
commandContext.changeStore(Integer.valueOf(storeId));
commandContext.setStoreId(Integer.valueOf(storeId));
commandContext.setUserId(Long.valueOf(userId));
requestProperties.put("logonPassword", CICPWD2_CP_Password_2);
requestProperties.put("logonPasswordVerify", CICPWD2_CP_Password_2);
requestProperties.put("logonId",CICNUM_Customer_Number + CICLOG_CP_Logon);
requestProperties.put("firstName", CICFNANE_CP_First_Name);
requestProperties.put("lastName", CICLNME_CP_Last_Name);
requestProperties.put("email1", CICMAIL_CP_Mail);
requestProperties.put("phone1", CICTEL_CP_Tel);
requestProperties.put("storeId", storeId);
requestProperties.put("preferredLanguage", langId);
requestProperties.put("URL", "URL=/webapp/wcs/stores/servlet/");
UserRegistrationAddCmd userRegAddCmd =
(UserRegistrationAddCmd) CommandFactory.createCommand(
UserRegistrationAddCmd.NAME, getStoreId());
userRegAddCmd.setCommandContext(commandContext);
userRegAddCmd.setRequestProperties(requestProperties);
userRegAddCmd.execute();
uab.refreshCopyHelper();
String mId = uab.getMemberId();
Long mIdLong = Long.valueOf(uab.getUserId());
try {
address = address.findSelfAddressByMember(mIdLong);
} catch (Exception e) {
e.printStackTrace();
throw new ECSystemException(
ECMessage._ERR_REMOTE_EXCEPTION,
"extCustomerRegistrationCmdImpl",
"performExecute");
}
address.setFax1(CICFAX_CP_Fax);
address.commitCopyHelper();
l***@knuerr.com
2006-11-13 21:08:18 UTC
Permalink
Thanks a lot Geo!
Your answer sounds very logical but my knowledges are not enough to understand it:
1. What does it mean "pushdown query"?
2. How can I do command chaining? How can I do forward? It is a command which is driven by MQ messages.
3. I didn't find into the command context a self address:-(

I will appreciate if you give me answers or say me - where I can read more about that.

Best Regards,

Lachezar
l***@knuerr.com
2006-11-14 11:17:39 UTC
Permalink
I have managed to find the self address Id in command contex:-)
But I have still a problem to understand how can I make command chain:-( :-(
geo
2006-11-15 13:32:17 UTC
Permalink
I am confused, if you have the selfAddressId I thought you would not need
the command chaining.
Post by l***@knuerr.com
I have managed to find the self address Id in command contex:-)
But I have still a problem to understand how can I make command chain:-( :-(
l***@knuerr.com
2006-11-15 16:04:57 UTC
Permalink
It is true. I have solved this problem thanks your tip with self address ID. But I want to understand how can I make a command chain for a command which is a response for a MQ-message.
Continue reading on narkive:
Loading...