Best method to trigger events in a constantly-running program?

I need to have a particular Java application always running in the background on my Linux machine (like a daemon) (it's a singleton -- no two instances will run simultaneously). However, I need to be able to send "events" to this application from another program, where an event is as simple as a line of text that the application interprets as some action. These events will be invoked by a non-Java program, so it should be possible for them to be called by, for example, a shell script that is executed. What's the best way to do this? The only idea I could come up with is:
The program writes the event to a file. The main Java application watches a particular file for changes -- when it encounters changes, it reads the file and takes the appropriate action.
Anything more elegant than that?
EDIT: Would it be better to have my main application listen on a particular port, and have the invoking application send the event information across that port?
Edited by: Tony_R on Dec 6, 2009 10:12 PM

Tony_R wrote:
The program writes the event to a file. The main Java application watches a particular file for changes -- when it encounters changes, it reads the file and takes the appropriate action.
Anything more elegant than that?See below.
EDIT: Would it be better to have my main application listen on a particular port, and have the invoking application send the event information across that port?Yes, a local socket is usually the best solution. On Unix, it might be possible to use a (named) pipe, but sockets should work just fine and are the standard solution for this sort of thing.

Similar Messages

  • Q: Best Method for TCL scripts to pass info between routers?

    I want to have routers tell each other how busy their links are.  Whats the best method to pass information between TCL scripts running on different routers?
    Thanks!
    Tim

    Likely the easiest approach is to use SNMP traps from one router to another.  See https://supportforums.cisco.com/message/3713232#3713232 for an example.

  • Best method for 8 channel analog control on a microsecond scale

    Thanks for the quick reply, it was most helpful.
    Now that I am restricted to the analog channels I was just wondering as to the best method of control.
    At present I am using the AO Generate waveforms VI, by feeding it a pre-built arrays of data for each of the channels. I found this gave 30us resolution (on the maximum 32767 updates/sec) between values. It doesn't seem as though this is utilising the onboard timer on the card however, rather simply ouputting the signals as quick as possible.
    I tried using one of the counting time or events VIs which utilised the onboard timers, however I had it in a case structure to trigger at certain times which was highly limited by software (as i presumed).
    Basically I was wondering how I can take advantage of the onboard timers to simply trigger voltage changes on channels on a microsecond timescale, I'm sure there is a simple way that is passing me by.
    Any help would be appreciated
    AndyB

    Take a look at the "Function Generator" example under the AO section of the hardware I/O.
    While take a look at the examples that might also intrest you.
    Just aply the same array you are using now to set up the I/O.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Best method for incremental replication to backup xserve?

    I was just trying to figure out what would be the best method for routinely incrementally replicating a primary xserve. I have a secondary that has the same hardware. I thought about using scheduled tasks with Carbon Copy Cloner over say a Crossover cable to the secondary xserve. However, doing this backup would continually wipe out the network settings for the secondary mac? I could do the replication to a secondary drive and then just make that drive the boot drive in the event of data corruption on the master server?
    Where I'm at now is that the primary server runs Raid1, so in the event of a single drive failure or a hardware failure, I could swap the drives into the backup server. However, I'd like some sort of protection against data corruption on the primary xserve.
    Any general thoughts on a better way to do this? Or is there software that does this well?
    Thanks

    Our primary is an XServe RAID. In addition it has an external 2TB drive that I CCC all the user accounts to every night. I then setup a Mac Mini Server as a replica.
    If the primary XServe has a catastrophic failure, I simply connect the 2TB drive to the Mac Mini and point the replicated user accounts to the cloned data on the 2TB drive.
    I haven't tested it. But this scenario seemed like the best solution.
    Message was edited by: MacTech_09

  • Best Method For Connection - JDev Team Help

    Hi,
    We are using a couple of different methods for obtaining a connection and pooling. I'm wondering what is the best method, though...if there is a preferred approach?
    One approach is getting the ApplicationModuleRef from the request. We then release the amref as true/true or true/false (pending of if we need to maintain state), but we definitely try to release true/false whenever possible.
    The other approach is using createRootApplicationModule. We then either release it back to the pool false or destroy it immediately w/ true.
    Is there a preferred approach between the two? We are constantly struggling with inactive sessions that are not getting cleaned up when they reach our timeout limit which is causing severe memory issues with our application. Is one of our methods for obtaining the connection and releasing perhaps causing our pooling issues?
    Any help on this would be greatly appreciated!
    Thanks!
    Andy Hamilton - TUSC

    That is exactly the problem and with 100+ users on the system at one time our connection count gets large quite rapidly. The issue only occurs though with sessions released true/true...they are never reused, just new connections piled on top.
    We are actually turning connection pooling on in hopes of it resolving our connection issues. Any idea though why if you release an amref true/true and then attempt to do a session.invalidate you would get this error:
    java.lang.NullPointerException     at oracle.jbo.server.DefaultTxnHandlerImpl.handleRollback(DefaultTxnHandlerImpl.java:125)     at oracle.jbo.server.DBTransactionImpl.doRollback(DBTransactionImpl.java:3417)     at oracle.jbo.server.DBTransactionImpl.rollback(DBTransactionImpl.java:1650)     at oracle.jbo.common.ampool.ApplicationPoolImpl.resetApplicationModule(ApplicationPoolImpl.java:885)     at oracle.jbo.common.ampool.ApplicationPoolImpl.removeSessionCookie(ApplicationPoolImpl.java:546)     at oracle.jbo.common.ampool.SessionCookieImpl.timeout(SessionCookieImpl.java:365)     at oracle.jbo.http.HttpSessionCookieImpl.timeout(HttpSessionCookieImpl.java:80)     at oracle.jbo.http.HttpContainer.fireTimeout(HttpContainer.java:516)     at oracle.jbo.http.HttpContainer.timeout(HttpContainer.java:241)     at oracle.jbo.http.HttpContainer.valueUnbound(HttpContainer.java:308)
    Thanks!
    Andy

  • Best method for timestamping? (for later use with perl script)

    What is the best method that I can use to timestamp events in Linux for later use with perl script?
    I am performing some energy measurements.. where I am running several tasks separated by 20 secs in between. Before I start any execution of tasks, I always place initial delay for me to start the script and start the measurement device.
    My problem is that I don't know how long is that first delay exactly. So to solve this, I thought I could use date commands to time stamp all tasks.. or at least to timestamp first dela.
    Here is example of what I am doing:
    1st delay
    task 1
    20s
    task 2
    20s
    task 3..... etc
    What would be the best to use?

    logger.
    It posts messages straight to the system log.  You can see the message, in all its glory using tools like journalctl.  You will see the message, the date, time, host name, user name, and the PID of logger when it ran.

  • Best Method for transferring projects back and fourth

    Hello. I will soon be purchasing an iMac for home use and would like to get some advice on project transfer. I will be doing a lot of video editing back and fourth between the office and home. What is the best method for doing this? Where can i locate the files to make sure that I have everything and wont be missing anything when I bring it home, etc. Thanks for any advice!
    Brandon

    Use a (Firewire 800 or faster) external HD to keep your media, events and projects on.
    You can then take the drive to work with you and back home. Use FCP X to transfer (or create) the event and projects on this drive and both macs will recognise it.
    The drive must be formatted Mac OS Extended (journaled is not important for video drives).
    Andy

  • Best method for UIComponent Initialization?

    I have a custom class that extends Panel and I would like to
    get input on the best method for initializing custom properties
    upon object creation. I currently create an event handler for the
    FlexEvent.CREATION_COMPLETE event and assign my properties then.
    However, I'd like to slim my code down. Is there a place I
    can initialize properties without having to import events? I tried
    overriding some protected methods such as commitProperties, but
    discovered this method gets called again by Flex when effects are
    done playing on the UIComponent. I don't want to initialize my
    custom parameters again because this is essentially reseting any
    interaction the user did with it.
    Is there another super method I can use to initialize my
    method rather than use CREATION_COMPLETE events?
    Thanks.

    The simplest and cheapest option is LifeFlix.  They have more info at www.lifeflix.com or on the Mac app store at https://itunes.apple.com/us/app/lifeflix/id630212114?ls=1&mt=12

  • Best method for importing mini DV tape movies directly to an external seagate hard drive for later import to iMovies ??

    Best method for importing mini DV tape movies directly to an Seagate external hard drive,for later import to imovie event???

    The simplest and cheapest option is LifeFlix.  They have more info at www.lifeflix.com or on the Mac app store at https://itunes.apple.com/us/app/lifeflix/id630212114?ls=1&mt=12

  • Best method for data acquisitio​n applicatio​n

    Another Newbie question:
    I have a different application that I am working on (preliminary development stage) and I would to perform the following steps but I am not quite sure what the best method to complete the task
    1) acquire data   
    2) wait 60 minutes (at this point at a later time I will add code to turn oven on)
    3) acquire data
    4) wait 60 minutes ( at this point, at a later time I will add code to turn oven OFF)
    5) acquire data
    6) END
    Currently I am using a modified example of the Agilent 34970A.  I can sucessfully contol the agilent meter and get data using labview (chart and log to lvm only).
    I am looking ahead for the main intention:
    Ideally the user of the application will list channels desired to acquire data from and make an association to a serial number (havent figured this part out yet) and then push the START button and walk away.  At the very end the Initial / Hot / Return data would be obtained, calculations performed, and a printout made.
    I am looking a good starting point to work off of whereby I can continue my baby steps.  Should I use Event driven or a sequence?
    Any good examples?
    Thank you for your time

    jqm,
    It seems like you have figured a good state machine model for your application. I am attaching a more elaborate state machine example than what is available in Example Finder. It uses a Producer/Consumer scenario with queues to pass data between two loops. You can follow that example to create your application. You might not be able to run the program unless you configure your Data Acquisition hardware to correspond to the software settings. However, you will be able to see the overall structure pretty well.
    Study the example well to see how data is passed from one state to another. For your wait time you can use either Elapsed Time VI or Wait VI.
    Hope that helps.
    Kalin T
    Applications Engineer
    National Instruments
    Kalin T.
    National Instruments
    Attachments:
    State Machine Example.zip ‏426 KB

  • Best Methods for Time, Tempo and Rhythm Alignment?

    Hello All, I am looking to edit some lengthy jams to concise segments. I wish to mix and match audio tracks (ex. drum section from begining with bass section in middle with guitar section at end). No metronome was used, so while the general structure (melody and rhythm) remained similar, tempos vary so that the parts don't match up perfectly. I know Logic has some pretty powerful time-based editing capabilities through its flex mode, but i am confused where the logical starting point would be for my situation. Do you think it would be to first chop up segments, pick a q-reference, set a global tempo, stretch or compress segments, and then individually correct any remaining rhythm alignment issues? What do you think are the best methods to accomplish this? I hope my questions are clear - if not please tell me. Thanks to anyone who cares and can help!
    JS

    Matt Woodward has some sample code on his blog to use the
    asyncronous event gateway to send email. The post is here :
    http://mattwoodward.com/blog/index.cfm?commentID=203
    This should take care of your timeout issues...
    Ross Valenti
    <edited to fix misspelled name >

  • Best Method Of Import For Future Preservation

    I would like to import all my home movies through iMovie to an external hard drive, but am wondering if that is the best method to ensure that I will always be able to use/access them in the years to come. A couple of questions:
    **Does iMovie still preserve and save to the external drive the original format the movie was recorded in? Does it switch it to something that only iMovie can recognize and find?
    **What if iMovie quits being made in 10 years or if I switch to a different editing program down the road? Will I still be able to use/access my movies?
    **Would it be better to skip going through iMovie and just copy the movies/files directly to the external drive?
    Thank you for any info you can give me.
    Nkulu

    Nkulu wrote:
    .. Does iMovie still preserve and save to the external drive the original format the movie was recorded in?
    in iMHD≤6: yes, even after editing, the unaltered original video is kept untouched; in iM08 answer is more complicated: the Events store the original data, but it is unable to export without altering it.. And: mpeg2 and AVCHD files get automatically converted.. but into a lossless codec ..
    Does it switch it to something that only iMovie can recognize and find?
    the .mov digged deep into the file structure of iM (in iMHD6: in the project packages; in iM08: in the Events Folder) are playable without iM..
    .. What if iMovie quits being made in 10 years or if I switch to a different editing program down the road? Will I still be able to use/access my movies?
    very hard to tell; my experience: cross-app/cross-platform, accessability is .. small. compare with 'opening iMHD6 project with iM08' , or 'transfer iM08 to FCE' .... and those are actual apps from one manufacturer..
    .. Would it be better to skip going through iMovie and just copy the movies/files directly to the external drive?
    that's why I'm in the process of decision making come back to tape (HDV) - I'm storing about an terabyte of my son's life on video in a simple shoebox.. no copying, backup, no transfer.. as long as I get some service which is able to playback that worlwide standard, I can watch and use those videos..
    I often tell that situation: me being on Cuba, running out of 'storage space' ... 7$ and got a new tape, 60min.. imagine that with a fancy HDDcorder.. you need additionally in your travel luggage your Mac, power brick, prob. an ext. harddrive, just for 'emtpying' your camcorder .. honestly: not on MY vacations/my hotel rooms, tents.. ..
    and don't tell me '17h recording time' .. IF HiDef camcorder, than FullHD.. which is actually a max. of 3h per device.. and I do record more than 3h on a 2 weeks journey..

  • Bootsplash trigger events

    on the bootsplash webpage it says to
    trigger events during bootup
    we suggest that you add a function to your init scripts that is called every time an init script is started. This can either be done in the runlevel scripts themselves or by the script/program scheduling it (i.e. /etc/init.d/rc)
    function rc_splash()
    test "$SPLASH" != "no" && test "$_rc_splash" -eq 1 && /sbin/splash "$1"
    progress=$(( $progress + 1 ))
    when adding the rc_splash call to your runlevel script scheduler, do it
    about like this:
    for i in $runrc/S${rex}*; do
    # send information to bootsplash handler.
    rc_splash "$i start"
    done
    but where is the archs program scheduling file., as i dont seem to see a /etc/init.d/rc, im tying to get the  Default Linux theme at bootsplashes webpage to work.. i got everything to work except silent mode to display the silent Jpeg and gradient bar
    thanks
    -bolero

    I have now gotten the progress bar to work. After trying a couple different approaches, this is my best shot. In /etc/rc.d/functions I extended stat_busy(), stat_done() and stat_fail() to look like this:
    stat_busy() {
    echo -ne "$C_OTHER$PREFIX_REG $C_MAIN$1$C_CLEAR "
    deltext
    echo -ne " $C_OTHER[${C_BUSY}BUSY$C_OTHER]$C_CLEAR "
    [ "$BOOTSPLASH_PROGRESS" -a "$BOOTSPLASH_DELTA" ] &&
    BOOTSPLASH_PROGRESS=$(($BOOTSPLASH_PROGRESS+$BOOTSPLASH_DELTA))
    stat_done() {
    deltext
    echo -e " $C_OTHER[${C_DONE}DONE$C_OTHER]$C_CLEAR "
    [ "$BOOTSPLASH_PROGRESS" -a -w /proc/splash ] &&
    echo "show $BOOTSPLASH_PROGRESS" > /proc/splash
    stat_fail() {
    deltext
    echo -e " $C_OTHER[${C_FAIL}FAIL$C_OTHER]$C_CLEAR "
    [ "$BOOTSPLASH_PROGRESS" -a -w /proc/splash ] &&
    echo "show $BOOTSPLASH_PROGRESS" > /proc/splash
    The idea is that $BOOTSPLASH_PROGRESS holds the current value of the progress bar (which is in the range 0 - 65535) and $BOOTSPLASH_DELTA is the amount to increase the progress counter with on each stat_busy. These values are initialized in rc.sysinit like this:
    [ "$BOOTSPLASH_SYSINIT" ] ||
    BOOTSPLASH_SYSINIT=`grep -c -e stat_busy -e status /etc/rc.sysinit`
    [ "$BOOTSPLASH_LOCAL" ] ||
    BOOTSPLASH_LOCAL=`grep -c -e stat_busy -e status /etc/rc.local`
    BOOTSPLASH_DAEMONS=`echo ${DAEMONS[@]} | sed 's/![^ ]*//g' | wc -w`
    BOOTSPLASH_ALL=$(($BOOTSPLASH_SYSINIT+$BOOTSPLASH_LOCAL+$BOOTSPLASH_DAEMONS))
    BOOTSPLASH_DELTA=$((65535/$BOOTSPLASH_ALL))
    BOOTSPLASH_PROGRESS=$((65535-$BOOTSPLASH_ALL*$BOOTSPLASH_DELTA))
    I put this right before the point where local file systems are mounted, because the progress bar can't be updated before /proc is accessible. Another option is to initialize these variables in the beginning of rc.sysinit to make earlier stat_busy calls get counted, but the updates won't be visible before /proc is mounted anyway.
    Because there is no way to export these variables from rc.sysinit to init's environment, rc.multi has to calculate them from scratch. Also the loop that starts daemons has to increase the counter because the daemon scripts can't export the new values. My full rc.multi script looks like this:
    . /etc/rc.conf
    . /etc/rc.d/functions
    [ "$BOOTSPLASH_SYSINIT" ] ||
    BOOTSPLASH_SYSINIT=`grep -c -e stat_busy -e status /etc/rc.sysinit`
    [ "$BOOTSPLASH_LOCAL" ] ||
    BOOTSPLASH_LOCAL=`grep -c -e stat_busy -e status /etc/rc.local`
    BOOTSPLASH_DAEMONS=`echo ${DAEMONS[@]} | sed 's/![^ ]*//g' | wc -w`
    BOOTSPLASH_DELTA=$((65535/($BOOTSPLASH_SYSINIT+$BOOTSPLASH_LOCAL+$BOOTSPLASH_DAEMONS)))
    BOOTSPLASH_PROGRESS=$((65535-($BOOTSPLASH_LOCAL+$BOOTSPLASH_DAEMONS)*$BOOTSPLASH_DELTA))
    export BOOTSPLASH_PROGRESS BOOTSPLASH_DELTA
    # Start daemons
    for daemon in "${DAEMONS[@]}"; do
    if [[ `echo $daemon | grep '^[^!]' | wc -l` -eq 1 ]]; then
    /etc/rc.d/$daemon start
    BOOTSPLASH_PROGRESS=$(($BOOTSPLASH_PROGRESS+$BOOTSPLASH_DELTA))
    fi
    done
    if [ -x /etc/rc.local ]; then
    /etc/rc.local
    fi
    Like I mentioned in my previous post, it's hard to know how many steps the bar is going to need. Especially rc.sysinit is full of conditional stat_busy statements. Therefor I made it possible to specify $BOOTSPLASH_SYSINIT (number of steps in rc.sysinit) in rc.conf. With the current rc.sysinit script this value is calculated as 19, but on my system rc.sysinit only executes 8 of the steps after the point where /proc is mounted.
    The code presented here doesn't display text for the different stat_busy calls. I kind of had that working as well, but the texts were written on top of each other (old text wasn't erased) and you had to source the bootsplash-theme to get the text's font and position - it wasn't pretty.
    I hope somebody finds this useful, and I might make a bootsplash package that includes the splash utils, an Arch theme and patches for the init scripts.
    -bogomipz

  • Best method to add ISCSI storage to a fileserver vm guest

    Hello,
    I have two Dell PowerVault NX3300 servers (Server 2012 R2), and one Equallogic PS6100 SAN.  The two servers are clustered together and host Hyper-V guests.  At this point, I'm running a 2012 R2 VM guest and can successfully migrate/failover
    between the nodes.  This guest VM will be a file server, and it will be accessing/sharing data that is stored on the SAN.  My question is: what is the best method to get the ISCSI SAN volume connected to this VM guest?  Since the vm
    guest is clustered between the two nodes, I need to make sure that it can access the SAN volume in an event of a failover.
    *** Note: We plan on having a total of two different file server VM guests that will each connect to the SAN.  There may be more guest VMs created in the future, but they would not be file servers.
    Each server has 8 physical NICs and are configured as follows on each server:
    1 x management port
    3 x VM nic team
    2 x SAN ISCSI connections
    (That leaves 2 open ports on each server)
    There is a ISCSI SAN volume attached to the hosts as the cluster's CSV.  This is only to store VM guests - not data.
    After reading multiple blog posts and other sites, I've come to realize that there may be two realistic options: (1) add the ISCSI SAN volume directly to the hosts, then add the disk to the VM as a pass-through and let the cluster configure it; (2)
    add the ISCSI SAN volume directly to the VM guest. 
    Option 2 sounds simpler, but I'm also curious as to the best configuration of vNICs for the guest. 
    Any help with this would be great.  If I'm missing something, please let me know!
    Thank you

    Hi Brain,
    I would like to check if you need further assistance.
    Best Regards
    Elton JI
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • No "before new record saved" trigger event in workflow definition ?

    Hello,
    I have following problem: I have to make a simple integration, where products have information about available quantity of given product . Assume we have field - it is called "Available amount" and it tells how many products are on stock. Now suppose we have created an opportunity, and we want to add Opportunity Product Revenue - we're selecting product and then quantity. I want to make OCOD to display message and prevent from adding opportunity product revenue, when its quantity is greater than "Available amount" field which is present in associated product record. I've created small C# application and used workflows to create Integration events. It works - but not exaclty how I want it - when I add a new record the workflow generates integration event - but I'd like to generate integration event before a record is created, also I'd like to show a notification from OCOD. But for "revenue" we do not have a trigger event called for example : "before new record saved" - we have only "when new record saved" and "before modified record saved".

    Hi,
    From your requirement, it seems you, want some kind of check. Did you try puting this validation on field level, i guess you would need to join fields and compare in field validation. So, whenever user creates a new record this validation kicks and user is notified of the error.

Maybe you are looking for

  • Error in photo iview of MSS

    Hi All, I have implemented ESS and MSS on EP6.0 SP9.I am getting following portal runtime error in the photo iview of the employee profile workset in MSS. Error in executing a process for compilation. I checked the log file for the deatils..which sho

  • Driver Issue on Vista x32

    Since I have upgraded to Vista from XP I am having trouble accessing my phone. My phone model is a 7250i and I connected through CA-42 I downloaded the new Nokia PC Suite which is compatible with Windows Vista. I followed instructions to install PC S

  • When I use the trial version of adobe elements why does it have adobe trial across my work?

    When I use the trial version of adobe elements why does it have adobe trial across my work?

  • How to erase all data on E71x ?

    I just bought an E71x and I really regret. Because : 1. batter--hard to take it in/out 2. Sync--no contact group function when sync with outlook. I have to group my contact manually 3. Voice command sucks 4. Very hard to hard rese/erase all data afte

  • Webpage Link Buttons

    Hi, The webpage I'm developing is going to use flash buttons as the main links. Theres 5 - 6 buttons that will be laid out horizontally across the screen in the header section. I was wondering which approach is better... to create a single flash movi