WLSTException: Error cding to the MBean while creating JMS Queue - weblogic

I am trying to create JMSQueue with following code but getting error on
cd ('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource/Queues/SampleQueue')
When I connected to server runtimeand check I can see JMS Module is not available, but from Admin Console I can clearly see it's (JMS Module BAMJMSSystemResource) available, also it's not giving errors for
Note : I am creating JMS module before calling createJMSQueue function )
def createJMSQueue(jmsQueueName, jmsModuleName, jndiName, subdeployment):
print ' Creating Queue '+jmsQueueName
cd('/')
cd("/JMSSystemResources/"+jmsModuleName+"/JMSResource/"+jmsModuleName)
cmo.createQueue(jmsQueueName)
print('DEBUG >> '+jmsModulePath+'/Queues/'+jmsQueueName)
cd("/JMSSystemResources/"+jmsModuleName+"/JMSResource/"+jmsModuleName+'/Queues/'+jmsQueueName)
set('JNDIName',jndiName)
set('SubDeploymentName',subdeployment)
cd('/JMSSystemResources/'+jmsModuleName+'/SubDeployments/'+subdeployment)
cmo.addTarget(getMBean('/JMSServers/BAMMonitoringServer'))
Error is ,
Starting an edit session ...
Started edit session, please be sure to save and activate your
changes once you are done.
*** Creating JMS Queues ....
Creating Queue SampleQueue
DEBUG >> JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource/Queues/SampleQueue
No stack trace available.
Problem invoking WLST - Traceback (innermost last):
File "/home/oracle/JMSConfigurations.py", line 188, in ?
File "/home/oracle/JMSConfigurations.py", line 77, in createJMSQueue
File "<iostream>", line 182, in cd
File "<iostream>", line 1847, in raiseWLSTException
WLSTException: Error cding to the MBean
Would really like to understand what's wrong ?

Shanaka, there could be problem in 'cd' command given after the DEBUG statement. You can give the cd line as below:
cd(jmsModulePath+'/Queues/'+jmsQueueName)
You can also get some more clarity on JMS module creation using WLST by Examples

This section of script looks fine except mix of double and single quote in " cd("/JMSSystemResources/"+jmsModuleName+"/JMSResource/"+jmsModuleName+'/Queues/'+jmsQueueName)"
and assigning target "cmo.addTarget()" , you dont need to target queue if sub-deployment is already targeted to JMS server.
You can check if your edit session of creating JMS module,Sub deployment, target JMS module to server and sub deployment to JMS server is activated successfully.
Then this Queue creation should work fine.
regards,
Kshitij

That can mean that the JMS you are trying to create already exists in WebLogic. Confirm that the JMS names are not existing ones.

I share with you my correct code:
def create_jms_object(name, module, subdeployment, type):
cd('/JMSSystemResources/'+module+'/JMSResource/'+module)
myob=create(name, type)
myob.setJNDIName("jms/"+name)
myob.setSubDeploymentName(subdeployment)
and I call the function here:
queue_name = queue['name']
sub_depl_name = queue['sub_deployment']
if(not_exists_jms_ud_qeue(jms_module_name, queue_name)):
print 'Creating queue '+queue_name
create_jms_object(queue_name, jms_module_name, sub_depl_name, 'UniformDistributedQueue')
print 'Created queue '+queue_name
else:
print 'UniformDistributedQueue ' + queue_name + ' already exists'
cmo = cd('/JMSSystemResources/'+jms_module_name+'/JMSResource/'+jms_module_name+'/UniformDistributedQueues/'+queue_name+'/DeliveryFailureParams/'+queue_name)
redelivery_limit = queue.get('redelivery_limit',-1)
set('RedeliveryLimit', redelivery_limit)
errorDestinationName = queue.get('error_destination', None)
if (errorDestinationName is not None):
errorDestination = getMBean('/JMSSystemResources/'+jms_module_name+'/JMSResource/'+jms_module_name+'/UniformDistributedQueues/'+errorDestinationName)
set('ErrorDestination', errorDestination)
print 'Dead letter queue set to: '+errorDestinationName
else:
cmo.unSet('ErrorDestination')
print 'Dead letter queue unset'
cd('/JMSSystemResources/'+jms_module_name+'/JMSResource/'+jms_module_name+'/UniformDistributedQueues/'+queue_name+'/DeliveryParamsOverrides/'+queue_name)
redelivery_delay = queue.get('redelivery_delay',-1)
set('RedeliveryDelay', redelivery_delay)
time_to_deliver = queue.get('time_to_deliver',-1)
set('TimeToDeliver', time_to_deliver)
where the queue object is the following:
{
"name" : "events_reg_queue",
"sub_deployment" : "Registry-SD",
"redelivery_limit" : 1
}
and the following utility function:
def not_exists_jms_ud_qeue(jmsModuleName, jmsResourceName):
try:
myMBean = getMBean('/JMSSystemResources/'+jmsModuleName+'/JMSResource/'+jmsModuleName+'/UniformDistributedQueues/'+jmsResourceName)
if (myMBean is None):
return true
return false
except:
return true

Did you try traversing the path manually ?
You can traverse the /edit location using the wlst command line.
Use cd("") and ls() to traverse and list those properties you created.

Related

Why isn't Entrez NCBI API error handling working?

from Bio import Entrez, __version__
print('Biopython version : ', __version__)
id_list = ["NC_045512.2", "ON248099.1", "ON248101.1", "ON248104.1", "ON248107.1", "ON248108.1", "ON248109.1", "ON248110.1", "ON248114.1", "ON247234.1", "ON247236.1", "ON247240.1", "ON247242.1", "ON247243.1", "ON247244.1", "ON247245.1", "ON247246.1", "ON247247.1", "ON247248.1"]
try:
print ("Downloading "+str(id_list[ax]))
net_handle = Entrez.efetch(db="nucleotide", id=id_list[ax], rettype="fasta", retmode="text")
net_handle_gb = Entrez.efetch(db="nucleotide", id=id_list[ax], rettype="gbwithparts", retmode="text")
except (IOError):
print ("Waiting")
sleep (30)
tell.app( 'Terminal', 'do script "' + command+ ' && ' + "python3 'All Covid SSR.py'" +'"')
I'm using this try block to download files from NCBI API. Up to this point, the try block was working and the exception was handled as given here. Now it isn't. The code gets stuck in the try section. Returns no errors or exceptions, so it doesn't trigger the exception handler.
I've set max_tries = 1, sleep_between_tries = 1 and got the personal API_Key too.
For context, I'm using the exceptions block to restart the downloading code on Mac Terminal.
I need the try and except section to automatically restart the script when Entrez.efetch returns an error. There isn't any error. The code just gets stuck after
print ("Downloading "+str(id_list[ax]))
Any suggestions are welcome.
P.S. I thought of changing the default timeout for requests.get because that's the module Entrez uses to access the NCBI API. Haven't found a way to do that. (There is no timeout variable that you can set in the efetch module.)
An explanation would be great!

How to handle errors from reqMktData calls

Are there any examples on the net how to process errors when downloading data from Interactive Brokers using the IBrokers package? I've had a look at the package details and eWrapper and twsCALLBACK seem to handle this but I can't get them to work. For example the code below produces an error and R hangs, the error msg isn't processed. Thanks for any suggestions.
contract <- twsContract(0,
symbol="SPI",
sectype="XXX", #bad sectype
exch="SNFE",
primary="",
expiry= "20181220",
strike="",
currency="AUD",
right="",
local="",
multiplier = "25",
combo_legs_desc = "",
comboleg = "",
include_expired = "",
secIdType = "",
secId = "")
tws <- twsConnect()
data <- reqMktData(tws,contract,snapshot = TRUE)
You should append a "Disconnect" command to you code. Otherwise your program try to build to connections on the same port, that's not possible and it will not terminate.
I don't know the IBroker package very well, please check the command for disconnecting and append it to your code. Refresh your command line and rerun your code.
In addition, connect to IB Gateway instead of TWS by using that port number (check API settings of your IB Gateway application). In the settings choose a detailed Log.
Run your code again (after changing port number) and send your log file. Then I will try to help more. It's hard to help without any error message.

Queues with random GUID being generated in RabbitMQ server

Queues with a random GUID are being generated comming from exchange 'celeryresults'.
This happened when I fired a task from the shell, using delay method, but I forgot to enter parameters of my original function in the arguments list of delay.
Error displayed in terminal where I run the celery worker:
[2015-02-20 18:42:48,547: ERROR/MainProcess] Task customers.tasks.sendmail_task[1a4daf49-81bf-4122-8dea-2ee76c2a2ff8] raised unexpected: TypeError('sendmail_task() takes exactly 4 arguments (0 given)',)
Traceback (most recent call last):
File "/home/cod/workspace/envs/cod/lib/python2.6/site-packages/celery/app/trace.py", line 240, in trace_task
R = retval = fun(*args, **kwargs)
File "/home/cod/workspace/envs/cod/lib/python2.6/site-packages/celery/app/trace.py", line 438, in __protected_call__
return self.run(*args, **kwargs)
TypeError: sendmail_task() takes exactly 4 arguments (0 given)
How do I stop random queues from being generated? Why won't these messages use the default queue?
There is a difference between the broker (sends/receives messages) and backend (stores/fetches task results) in celery. It sounds like you are using RabbitMQ both as the message broker and the result backend.
When RabbitMQ is used as a result backend, celery creates one queue per task to temporarily keep track of the result. This is described in the RabbitMQ Result Backend section of the docs.
If you don't want this behavior then you should either turn it off using CELERY_IGNORE_RESULT or switch to one of the other backend implementations listed in the Result Backend Settings.

WLST capture the output of state('ms1') to a variable

I need to capture the output of the below to a variable.
I know we can get to serverRuntime or domainRuntime() trees and get the state. But need to get the below working.
wls:/owb/serverConfig> state('Server1')
Current state of 'Server1' : RUNNING
I tried two ways:
wls:/owb/serverConfig> print state('Server1')
Current state of 'Server1' : RUNNING
None
wls:/owb/serverConfig> x=state('Server1')
Current state of 'Server1' : RUNNING
wls:/owb/serverConfig> print x
None
You have to use the getState() method of server runtime mbean.
You can obtain the server runtime mbean by navigating into wlst runtime tree or by using a lookup method.
Sample:
domainRuntime()
slrBean = cmo.lookupServerLifeCycleRuntime('Server1')
status = slrBean.getState()
print 'Status of Managed Server is '+status
See also Getting Runtime Information in WLST official documentation.
This same question was raised by Dianyuan Wang with me 2011.
Here is the steps to resolve your issue.
1. Capture the output of state command using redirect, stopRedirect command
2. Use the Python regular expression in search function to extract the desired server output.
Code snippet is here
fileName='/tmp/myserver_state.txt'
redirect(fileName)
state(server_nm,'Server')
stopRedirect()
f = open(fileName)
try:
for line in f.readlines():
if re.search('Current state',line):
status[server_nm]=line
except:
continue
Now you can apply desired logic after this block.
Cheers!!
HTH
Here is what I am using and is working like charm
cd("/ServerRuntimes/ms1")
state=cmo.getState()
print state

Twisted IRC Bot connection lost repeatedly to localhost

I am trying to implement an IRC Bot on a local server. The bot that I am using is identical to the one found at Eric Florenzano's Blog. This is the simplified code (which should run)
import sys
import re
from twisted.internet import reactor
from twisted.words.protocols import irc
from twisted.internet import protocol
class MomBot(irc.IRCClient):
def _get_nickname(self):
return self.factory.nickname
nickname = property(_get_nickname)
def signedOn(self):
print "attempting to sign on"
self.join(self.factory.channel)
print "Signed on as %s." % (self.nickname,)
def joined(self, channel):
print "attempting to join"
print "Joined %s." % (channel,)
def privmsg(self, user, channel, msg):
if not user:
return
if self.nickname in msg:
msg = re.compile(self.nickname + "[:,]* ?", re.I).sub('', msg)
prefix = "%s: " % (user.split('!', 1)[0], )
else:
prefix = ''
self.msg(self.factory.channel, prefix + "hello there")
class MomBotFactory(protocol.ClientFactory):
protocol = MomBot
def __init__(self, channel, nickname='YourMomDotCom', chain_length=3,
chattiness=1.0, max_words=10000):
self.channel = channel
self.nickname = nickname
self.chain_length = chain_length
self.chattiness = chattiness
self.max_words = max_words
def startedConnecting(self, connector):
print "started connecting on {0}:{1}"
.format(str(connector.host),str(connector.port))
def clientConnectionLost(self, connector, reason):
print "Lost connection (%s), reconnecting." % (reason,)
connector.connect()
def clientConnectionFailed(self, connector, reason):
print "Could not connect: %s" % (reason,)
if __name__ == "__main__":
chan = sys.argv[1]
reactor.connectTCP("localhost", 6667, MomBotFactory('#' + chan,
'YourMomDotCom', 2, chattiness=0.05))
reactor.run()
I added the startedConnection method in the client factory, which it is reaching and printing out the proper address:host. It then disconnects and enters the clientConnectionLost and prints the error:
Lost connection ([Failure instance: Traceback (failure with no frames):
<class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly.
]), reconnecting.
If working properly it should log into the appropriate channel, specified as the first arg in the command (e.g. python module2.py botwar. would be channel #botwar.). It should respond with "hello there" if any one in the channel sends anything.
I have NGIRC running on the server, and it works if I connect from mIRC or any other IRC client.
I am unable to find a resolution as to why it is continually disconnecting. Any help on why would be greatly appreciated. Thank you!
One thing you may want to do is make sure you will see any error output produced by the server when your bot connects to it. My hunch is that the problem has something to do with authentication, or perhaps an unexpected difference in how ngirc handles one of the login/authentication commands used by IRCClient.
One approach that almost always applies is to capture a traffic log. Use a tool like tcpdump or wireshark.
Another approach you can try is to enable logging inside the Twisted application itself. Use twisted.protocols.policies.TrafficLoggingFactory for this:
from twisted.protocols.policies import TrafficLoggingFactory
appFactory = MomBotFactory(...)
logFactory = TrafficLoggingFactory(appFactory, "irc-")
reactor.connectTCP(..., logFactory)
This will log output to files starting with "irc-" (a different file for each connection).
You can also hook directly into your protocol implementation, at any one of several levels. For example, to display any bytes received at all:
class MomBot(irc.IRCClient):
def dataReceived(self, bytes):
print "Got", repr(bytes)
# Make sure to up-call - otherwise all of the IRC logic is disabled!
return irc.IRCClient.dataReceived(self, bytes)
With one of those approaches in place, hopefully you'll see something like:
:irc.example.net 451 * :Connection not registered
which I think means... you need to authenticate? Even if you see something else, hopefully this will help you narrow in more closely on the precise cause of the connection being closed.
Also, you can use tcpdump or wireshark to capture the traffic log between ngirc and one of the working IRC clients (eg mIRC) and then compare the two logs. Whatever different commands mIRC is sending should make it clear what changes you need to make to your bot.