Streams with multiple writers

Here is a conundrum I've been unable to solve:
How do multiple threads write to a PrintWriter, and then disconnect without killing each other?
Here's the long version:
Consider a thread with two pipes:
PipedInputReader p1in = new PipedInputReader();
PipedOutputWriter p1out = new PipedOutputWriter(p1in);For speed, efficiency, and the desire to use the readline() method, this thread wants to wrap the input with a buffer:
BufferedReader in = new BufferedReader(p1in);Now, this thread wants to give access to the other end of the pipe to someone else, and wrap it in a BufferedWriter. In turn, that will be wrapped in an autoflushed PrintWriter so that we can use the println() method:
PrintWriter out = new PrintWriter(new BufferedWriter(p1out), true);Now we just need to give that to the outside world:
public PrintWriter getBuffer() {
return out
}Putting it all into a complete class (that may not be runnable due to typos; I'm doing this by hand), we get the following:
class buf implements Runnable {
  private PrintWriter out = null;
  public PrintWriter getBuffer() {
    return out
  public void run() {
    PipedInputReader p1in = new PipedInputReader();
    PipedOutputWriter p1out = new PipedOutputWriter(p1in);
    BufferedReader in = new BufferedReader(p1in);
    PrintWriter out = new PrintWriter(new BufferedWriter(p1out), true);
    String text = "";
    while ( (text = in.readline()) == true ) {  ;;;; }
  }Of course, toss in the try/catch blocks and all that. I probably missed a keyword here and there; eclipse does that for me :)
Now, this works remarkably well. 20 threads can call getBuffer on that thread and write to it, and everything is synchronized nicely. It really does work well enough for my needs.
However, when one of those threads exits, all the pipes close and everyone dies.
Say I have another thread that does the following:
PrintWriter xx = thethreadabove.getBuffer();I would think that somewhere along the line, when that thread is done, I can just do:
xx = null;And let the thread exit. I'd be wrong, however. It makes everything die. So, what can I do?
How can I have multiple writers with just a single reader? I am not locked into pipes wrapped by bufferedwriters wrapped by printwriters; they just provide what I need with little issue. I'm guessing someone will tell me at some point that I was supposed to use a queue of some sort (arrayblockingqueue, etc.), and I'm sure that might work with enough spit and tape. Streams should work too, though, shouldn't they? I should be able to remove one of many references to a PrintWriter without killing the underlying pipe, right?

Ok, so here's what I found. First, I had the reader thread export a PrintWriter by doing the following:
private MyBuffer outside
public ReaderThread() {
  outside = new MyBuffer(new BufferedReader(pipe))
public PrintWriter getBuffer() {
  outside.register();
  return (new PrintWriter(outside))
}The MyBuffer class is then:
public class MyBuffer extends FilterWriter {
  private int count = 0;
  public MyBuffer(Writer w) {
    super(w);
  public void register() {
    ++count;
  public void close() {
    --count;
    if (count <= 0)
      super.close();
}I couldn't for the life of me get that close method to be called. Even if I called it manually, things still fell apart, because after about 1 second, the pipe would close.
Here's what I found:
Pipes have a nice undocument / poorly documented feature wherein they will close 1 second after the last thread that wrote to the pipe exits. Crazy, eh? Pipes expect one and only one thread to do the writing, and have a rather lousy mechanism for even achieving that goal (proven by how I worked around it). They record the thread id of the last thread to write to the pipe. So if I have the aforementioned 20 worker threads that all get a pointer to the printwriter encapsulating the buffer encapsulating the pipe, and they each write to the printwriter, each write will change the value of the thread id that the pipe is looking for. If one of those threads dies and is listed as the last thread to conduct a write, then the whole pipe shuts down, causing a ripple effect of broken pipes.
This is a very inneffective design, and even the source code for the java sdk contains comments saying that there should be a better way. Until that ever gets fixed, I'm left with having to signal another thread to do a write before the dying thread can terminate. This is not very safe in the case of a real problem with a given thread, but at least it works in terms of the "go-path".
Craziness.
If anyone can think of a good way to handle this, I'm open. I'm thinking write now that I need a separate thread to do the watching, and dying threads need to signal that thread to take over as the "last writer". Either that, or maybe work up an event listener to trigger on every write. I really don't know. This is disappointing really.

Similar Messages

  • Dynamically create Variant Data Socket items with multiple writers

    I want to use variant or cluster items with data socket connection. I want to allow multiple writers.
    So far I can create these items dynamically but not set them to allow multiple writers.
    For numeric, string, and Boolean items I can set these properties by predefining them in the data socket server manager. I could not predefine a variant or cluster in the manager.
    I realize I can flatten to string the item needed but would prefer to do this in the cluster or variant formats.
    Any suggestions?

    unclebump wrote:
    Could you accomplish this using a functional global architecture??
    An interesting concept which might work and did just open up a new host of possibilities!
    When I get the time I might give this a try. I just did a quick test in another program.
    Through VI server I opened a reference to a remote machine. I then created strictly typed reference to a “functional global vi” that I knew would be in memory. It reads the functional global just fine!
    Thanks for the suggestion.
    Here is the work around I used for the data socket program.
    Here is the original problem.
    I needed to know on the server side when a new value was written to the message cluster, which consisted of a string and a variant. Checking the string portion of the cluster let me know what command to send the device being controlled on the server machine. The variant is used to hold the various parameters that accompanied the command. Since the same command type could be sent several times I needed to reset the string control after the server read the command. This required writing to the data socket from the client & server machine (multiple writers). Also since the client could be any PC in the subnet I needed to allow all these machines to have write access.
    I solved this by using a second data socket item for the new message flag. This item is a string value that could be pre-defined and set to allow multiple writers. I then used the cluster item to handle the commands and wrote to the string item a signal that a new command was ready. The server then recognizes a new command is ready, reads the command, and then flags the string message received.
    Thanks again for those who took the time to answer this.
    Randall

  • High Speed Streaming with Multiple FPGA FIFOs and TDMS Advanced Asynchronous (Data Ref)

    I am using an FPGA with adapter card (7962 with 5751) for data acquisition and signal processing. I have adapted the FlexRio example "High Throughput Streaming," which works very well for a transferring data from the FPGA via a single FIFO. This example uses the TDMS Advanced Asynchronous Write (Data Ref). The "High Throughput Streaming" example is similar to "Streaming External Data to a TDMS File (Windows)" but includes more code to prep the FIFO buffer size and TDMS size.
    My question is how can I adapt this code to incorporate multiple FIFOs that write data to different channels in the TDMS file? Can I use multiple instances of  TDMS Advanced Asynchronous Write (Data Ref) in a single VI for each FIFO Acquire Read Region? If so, how do I insure that the correct data is written to the correct channel in the TDMS file?

    Thank you DeppSu for your explanation, I will look into that.
    But first, I want to be sure that the FPGA and the Hot general designs are correct, which for the moment I am not sure. So I have included my code.
    I tried the Host vi several times, and it seems that it works sometimes and sometimes not, like there are some communication problems between the fpga and the host on the "read acquire region" method which is not executed. I managed to make it work randomly before, but not now. Maybe it is because of the reset that I added?
    If someone could check my code and help me, I would really appreciate it since nobody in my workplace has the expertise to do so :-) If you see some obvious mistake, please share with me, I also added some comment boxes in the code with questions.
    Delphine
    Attachments:
    thoughput.zip ‏1261 KB

  • WVC 210 and mobile streaming with multiple cameras?

    I have two WVC 210 and have opened ports 554, and 5000 for one of the camera's local IPs. This is allowing me to get to that "one" camera when I put in the camera's rtsp addresss with the passcode at the end.
    I was wondering is there any way to have it where I can route to both cameras? Is there a way to put the different addresses in like when you go through the browser? 

    I didn't see any discussions on SpiceWorks that covered this question. I'm involved in live streaming of my church's services, and we got hit by lightening 2 weeks ago. We had 3 cameras which were able to be remotely controlled by 1 Telemetrics box, and which sent video feed into a digital video mixer. Well, one of the cameras and the remote control box have died, so we are looking to replace the setup with better equipment. I'm able to run the equipment, and even troubleshoot it to an extent, but have no idea what's even out there. Does anyone have any recommendations on a setup for at least 3 remotely controllable (pan/tilt/zoom) HD cameras? The remote control could be either hardware or software based. I have no idea how much the church could budget for a new system, so a range of low-high cost options would be ideal for me to...
    This topic first appeared in the Spiceworks Community

  • Live streaming with multiple remote cameras?

    look up lts security, i found it as a easy, high quality, low cost,  and great solution 

    I didn't see any discussions on SpiceWorks that covered this question. I'm involved in live streaming of my church's services, and we got hit by lightening 2 weeks ago. We had 3 cameras which were able to be remotely controlled by 1 Telemetrics box, and which sent video feed into a digital video mixer. Well, one of the cameras and the remote control box have died, so we are looking to replace the setup with better equipment. I'm able to run the equipment, and even troubleshoot it to an extent, but have no idea what's even out there. Does anyone have any recommendations on a setup for at least 3 remotely controllable (pan/tilt/zoom) HD cameras? The remote control could be either hardware or software based. I have no idea how much the church could budget for a new system, so a range of low-high cost options would be ideal for me to...
    This topic first appeared in the Spiceworks Community

  • Photo stream with multiple folders

    Hi,
    Can’t Apple TV see more than one level of folders when streaming photos? i have the following folders hierarchy vacations-> 2007->Brazil for whatever reason when I set the shared folder to be “vacations” Apple TV claim that there are no pictures in the shared library. if I set the shared library to 2007 it will work and will see all my vacation’s folders under the 2007 folder. I remember that it used to work long time ago and Itune will stream the pictures in all the subfolders no matter if the folders are one or more level deep. any thoughts what is wrong?
    I use Win7, latest iTune, Apple TV v3.0.
    Thanks!

    Turn PhotoStream off on the device you want to exclude
    LN

  • Reading image stream with multiple threads

    Hello folks
    I thought about a model for an app I need to code and I need your opinion.
    My task is to implement an application that does the following:
    - Read and decode images from a stream.
    - Do some image processing
    - Display the resulting images in Swing window.
    Since decoding is expensive and i might want to use a multiprocessor machine,
    I decided to put the image reading and decoding in a different thread. from the
    image processing (and maybe painting).
    In the end, I thought about using 2 objects and 3 threads:
    - one object that keeps the Swing window data and the image processing logic
    - one object that keeps the stream connection data and the decompression logic
    for the (jpeg) images
    -one thread that waits for incoming events and decodes them. After decompressing
    one image, it sends an event to all objects that needs the image data, in this case
    this is the object that keeps the image processing logic. Therefore it updates an
    image reference in the image processing logics object. The image object only
    allow synchronized access by all threads.
    -another thread whose logic is inside the image processing logic object takes
    the current data from the image reference the first thread writes to via events
    and does image processing. The result is written to another image reference within
    the same object. After that, it sleeps for 10 ms or so.
    -a third thread is triggered via invokeLater by the image processing thread after
    it produced a result. It calls the repaint() method of the Swing control which draws
    the result-image to the screen.
    Do you see any mistakes or do you have better suggestions to do it?
    Please let me know!
    Thanks in advance!

    If the file is on a diskdrive, it's likely that your program will be i/o bound and threads won't help.
    Edited by: ChuckBing on Jul 2, 2008 11:32 AM

  • Multiple stream with FMLE

    Is FMLE capable to detect few inputs and to stream multiple streams with different settings?
    I would like to use DeckLink Duo with 2 sdi inputs, one SDI input would be HD signal other SD. Can I open two screens of FMLE and stream simultaneous?

    You can run multiple instances of FMLE and select different devices/stream settings in each. Just double-click FMLE, then double-click again, you'll get two windows that you can set the different configurations in.

  • Streaming from multiple user accounts......problem

    With my initial set up I had no problem. I have a large iTunes Library. 48k songs. Over 270 GB of files. I synced a few photos and some music for the AppleTV slide shows but everything else I was going to stream. Streaming is working wonderfully from MY user account but if I try and stream a similar sized library from another user account on the same computer it is "NO JOY". I get the "loading library" dialog with the little circle of dashes going round and round but it eventually gives up and does not load. I have tried this with iTunes running on my user account and with iTunes turned off on my user account and either way the library from the other user account will NOT load. I am at a loss here. The set up for the second user went smoothly. I clicked add a library and got a key code on my TV screen. AppleTV showed up in the devices column in iTunes of the second user account and accepted the key code but like I said earlier the library will just not load for streaming. Streaming from my first user account is still working well. I have not found any discussion topics dealing with streaming from multiple user accounts. Hopefully someone who is doing this will chime in and help me out if possible.

    The only way I have been able to get this to work is to quit the iTunes that I am currently streaming from. Switch (on the computer) users to the library I want to stream from. Start iTunes on that user. If I follow this I can get AppleTV to load the library of the second user. If I do NOT quit iTunes from the first user it will not load the second user's library. If I have iTunes from the second user running at the same time I quit the first user's iTunes it will NOT load the second users library. I guess it is a bug and will need to be fixed with the next software release. I would like to be able to switch among user libraries at will and independent of which user is currently using the computer.

  • Unable to share files when in a IM convo with multiple people Lync 2013

    Hello,
    I'm in the middle of a migration from lync server 2010 to lync server 2013. The users I have migrated over to lync 2013 are not able to send/share attachments when in a convo with multiple people.
    However, users can send/share files when IM'ing with individual people.
    I've been researching this issue for quite some time but still having a problem pinpointing  the issue.
    Any help would be greatly appreciated.
    Thanks.

    Hi,
    Did the issue also happen between users who still in Lync server 2010 pool?
    Did the issue happen internal or external?
    Please double check if MCU on Lync 2013 FE server works well, when two participants are connected, the session is essentially peer-to-peer. When three or more participants are connected, the Sharing feature depends on the Front End Server Multi Point Control
    Unit (MCU) to provide the sharing stream to all parties.
    Best Regards,
    Eason Huang
    Eason Huang
    TechNet Community Support

  • HT204053 i have 2 apple ids and one is from years ago when icloud wasnt a thought but now somehow it became my primary apple id and i cant photo stream with the apple id i use. Even if im signed into my old one the photo stream doesnt automatically go to

    i have 2 apple ids and one is from years ago when icloud wasnt a thought but now somehow it became my primary apple id and i cant photo stream with the apple id i use. Even if im signed into my old one the photo stream doesnt automatically go to my mac. Im not exactly technology savy but id love to figure this out.

    I have also noticed the same "problem".  I do not fully understand the impact of using the same ID on multiple computers and devices if I want to keep them all in sync.

  • Sending UTL_SMTP mail with Multiple attachment

    Hi,
    My Environment ----> Oracle Database 11g r1 on Windows 2003 Server (64Bit).
    The below script i used for sending mail with single attachment now i am trying to send mail with multiple attachment please tell me how to achieve this
    DECLARE
    /*LOB operation related varriables */
    v_src_loc BFILE := BFILENAME('DATA_PUMP_DIR', 'EXPORT.LOG');
    l_buffer RAW(54);
    l_amount BINARY_INTEGER := 54;
    l_pos INTEGER := 1;
    l_blob BLOB := EMPTY_BLOB;
    l_blob_len INTEGER;
    v_amount INTEGER;
    /*UTL_SMTP related varriavles. */
    v_connection_handle UTL_SMTP.CONNECTION;
    v_from_email_address VARCHAR2(30) := '[email protected]';
    v_to_email_address VARCHAR2(30) := '[email protected]';
    v_smtp_host VARCHAR2(30) := 'MAIL.EXPORT.COM'; --My mail server, replace it with yours.
    v_subject VARCHAR2(30) := 'MULTIPLE Attachment Test';
    l_message VARCHAR2(200) := 'TEST Mail for Multiple Attachment';
    /* This send_header procedure is written in the documentation */
    PROCEDURE send_header(pi_name IN VARCHAR2, pi_header IN VARCHAR2) AS
    BEGIN
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    pi_name || ': ' || pi_header || UTL_TCP.CRLF);
    END;
    BEGIN
    /*Preparing the LOB from file for attachment. */
    DBMS_LOB.OPEN(v_src_loc, DBMS_LOB.LOB_READONLY); --Read the file
    DBMS_LOB.CREATETEMPORARY(l_blob, TRUE); --Create temporary LOB to store the file.
    v_amount := DBMS_LOB.GETLENGTH(v_src_loc); --Amount to store.
    DBMS_LOB.LOADFROMFILE(l_blob, v_src_loc, v_amount); -- Loading from file into temporary LOB
    l_blob_len := DBMS_LOB.getlength(l_blob);
    /*UTL_SMTP related coding. */
    v_connection_handle := UTL_SMTP.OPEN_CONNECTION(host => v_smtp_host);
    UTL_SMTP.HELO(v_connection_handle, v_smtp_host);
    UTL_SMTP.MAIL(v_connection_handle, v_from_email_address);
    UTL_SMTP.RCPT(v_connection_handle, v_to_email_address);
    UTL_SMTP.OPEN_DATA(v_connection_handle);
    send_header('From', '"Sender"');
    send_header('To', '"Recipient"');
    send_header('Subject', v_subject);
    --MIME header.
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'MIME-Version: 1.0' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: multipart/mixed; ' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' boundary= "' || 'SAUBHIK.SECBOUND' || '"' ||
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Mail Body
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: text/plain;' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' charset=US-ASCII' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, l_message || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Mail Attachment
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: application/octet-stream' ||
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Disposition: attachment; ' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' filename="' || 'export.log' || '"' || --My filename
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Transfer-Encoding: base64' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    /* Writing the BLOL in chunks */
    WHILE l_pos < l_blob_len LOOP
    DBMS_LOB.READ(l_blob, l_amount, l_pos, l_buffer);
    UTL_SMTP.write_raw_data(v_connection_handle,
    UTL_ENCODE.BASE64_ENCODE(l_buffer));
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    l_buffer := NULL;
    l_pos := l_pos + l_amount;
    END LOOP;
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Close Email
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || '--' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    UTL_TCP.CRLF || '.' || UTL_TCP.CRLF);
    UTL_SMTP.CLOSE_DATA(v_connection_handle);
    UTL_SMTP.QUIT(v_connection_handle);
    DBMS_LOB.FREETEMPORARY(l_blob);
    DBMS_LOB.FILECLOSE(v_src_loc);
    EXCEPTION
    WHEN OTHERS THEN
    UTL_SMTP.QUIT(v_connection_handle);
    DBMS_LOB.FREETEMPORARY(l_blob);
    DBMS_LOB.FILECLOSE(v_src_loc);
    RAISE;
    END;
    Thank you
    Shan

    Hi Saubhik
    Thanks for your reply, below script i used to send mail with multiple attachments, plsql code is executing without any error messages and i am also able to receive mail with the multiple attachment.
    i used your code which u posted in OTN then i changed little bit as per my need, output is ok.but the problem is if i want to add one more file then i have to add more varaiables in the code. i want to make the code which i can add more attachments without adding more varaiables i don't know the way to do this. can u please give me some hints.
    Thanks for your help
    Shan
    Script Used:
    DECLARE
    /*LOB operation related varriables01 */
    v_src_loc BFILE := BFILENAME('DATA_PUMP_DIR', 'EXPORT.LOG');
    l_buffer RAW(54);
    l_amount BINARY_INTEGER := 54;
    l_pos INTEGER := 1;
    l_blob BLOB := EMPTY_BLOB;
    l_blob_len INTEGER;
    v_amount INTEGER;
    /*LOB operation related varriables02 */
    v_src_loc2 BFILE := BFILENAME('DATA_PUMP_DIR', 'EXPORT1.LOG');
    l_buffer2 RAW(54);
    l_amount2 BINARY_INTEGER := 54;
    l_pos2 INTEGER := 1;
    l_blob2 BLOB := EMPTY_BLOB;
    l_blob_len2 INTEGER;
    v_amount2 INTEGER;
    /*UTL_SMTP related varriavles. */
    v_connection_handle UTL_SMTP.CONNECTION;
    v_from_email_address VARCHAR2(30) := '[email protected]';
    v_to_email_address VARCHAR2(30) := '[email protected]';
    v_smtp_host VARCHAR2(30) := 'MAIL.EXPORT.COM'; --My mail server, replace it with yours.
    v_subject VARCHAR2(30) := 'MULTIPLE Attachment Test';
    l_message VARCHAR2(200) := 'TEST Mail for Multiple Attachment';
    /* This send_header procedure is written in the documentation */
    PROCEDURE send_header(pi_name IN VARCHAR2, pi_header IN VARCHAR2) AS
    BEGIN
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    pi_name || ': ' || pi_header || UTL_TCP.CRLF);
    END;
    BEGIN
    /*Preparing the LOB from file for attachment01. */
    DBMS_LOB.OPEN(v_src_loc, DBMS_LOB.LOB_READONLY); --Read the file
    DBMS_LOB.CREATETEMPORARY(l_blob, TRUE); --Create temporary LOB to store the file.
    v_amount := DBMS_LOB.GETLENGTH(v_src_loc); --Amount to store.
    DBMS_LOB.LOADFROMFILE(l_blob, v_src_loc, v_amount); -- Loading from file into temporary LOB
    l_blob_len := DBMS_LOB.getlength(l_blob);
    /*Preparing the LOB from file for attachment02. */
    DBMS_LOB.OPEN(v_src_loc2, DBMS_LOB.LOB_READONLY); --Read the file
    DBMS_LOB.CREATETEMPORARY(l_blob2, TRUE); --Create temporary LOB to store the file.
    v_amount2 := DBMS_LOB.GETLENGTH(v_src_loc2); --Amount to store.
    DBMS_LOB.LOADFROMFILE(l_blob2, v_src_loc2, v_amount2); -- Loading from file into temporary LOB
    l_blob_len2 := DBMS_LOB.getlength(l_blob2);
    /*UTL_SMTP related coding. */
    v_connection_handle := UTL_SMTP.OPEN_CONNECTION(host => v_smtp_host);
    UTL_SMTP.HELO(v_connection_handle, v_smtp_host);
    UTL_SMTP.MAIL(v_connection_handle, v_from_email_address);
    UTL_SMTP.RCPT(v_connection_handle, v_to_email_address);
    UTL_SMTP.OPEN_DATA(v_connection_handle);
    send_header('From', '"Sender"');
    send_header('To', '"Recipient"');
    send_header('Subject', v_subject);
    --MIME header.
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'MIME-Version: 1.0' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: multipart/mixed; ' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' boundary= "' || 'SAUBHIK.SECBOUND' || '"' ||
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Mail Body
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: text/plain;' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' charset=US-ASCII' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, l_message || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Mail Attachment01
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: application/octet-stream' ||
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Disposition: attachment; ' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' filename="' || 'export.log' || '"' || --My filename
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Transfer-Encoding: base64' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    /* Writing the BLOL in chunks */
    WHILE l_pos < l_blob_len LOOP
    DBMS_LOB.READ(l_blob, l_amount, l_pos, l_buffer);
    UTL_SMTP.write_raw_data(v_connection_handle,
    UTL_ENCODE.BASE64_ENCODE(l_buffer));
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    l_buffer := NULL;
    l_pos := l_pos + l_amount;
    END LOOP;
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Mail Attachment02
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: application/octet-stream' ||
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Disposition: attachment; ' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' filename="' || 'export1.log' || '"' || --My filename
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Transfer-Encoding: base64' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    /* Writing the BLOL in chunks */
    WHILE l_pos2 < l_blob_len2 LOOP
    DBMS_LOB.READ(l_blob2, l_amount2, l_pos2, l_buffer2);
    UTL_SMTP.write_raw_data(v_connection_handle,
    UTL_ENCODE.BASE64_ENCODE(l_buffer2));
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    l_buffer2 := NULL;
    l_pos2 := l_pos2 + l_amount2;
    END LOOP;
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Close Email
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || '--' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    UTL_TCP.CRLF || '.' || UTL_TCP.CRLF);
    UTL_SMTP.CLOSE_DATA(v_connection_handle);
    UTL_SMTP.QUIT(v_connection_handle);
    DBMS_LOB.FREETEMPORARY(l_blob);
    DBMS_LOB.FILECLOSE(v_src_loc);
    DBMS_LOB.FREETEMPORARY(l_blob2);
    DBMS_LOB.FILECLOSE(v_src_loc2);
    EXCEPTION
    WHEN OTHERS THEN
    UTL_SMTP.QUIT(v_connection_handle);
    DBMS_LOB.FREETEMPORARY(l_blob);
    DBMS_LOB.FILECLOSE(v_src_loc);
    DBMS_LOB.FREETEMPORARY(l_blob2);
    DBMS_LOB.FILECLOSE(v_src_loc2);
    RAISE;
    END;
    PL/SQL procedure successfully completed.
    Edited by: SHAN2009 on May 11, 2011 1:05 PM

  • Multiple writers for a field

    I get an error indicating that i have multiple writers for a field table_a.item_key. I have 3 classes that use this field as shown below.
    @Entity @Inheritance(strategy=InheritanceType.SINGLE_TABLE) ...
    @Table(name="table_a")
    @DiscriminatorColumn(name="item_Type")
    abstract class A {
    @Id, @Column(name="item_key")
    public String getItemKey(){
    @Inheritance(discriminatorValue="B")
    class B extends A {
    @OneToOne
    @JoinColumn(name="item_key", updatable=false, insertable=false)
    public C getC(){
    @Entity
    @Table(name="table_c")
    class C {
    @Id, @Column(name="item_key")
    public String getItemKey(){
    Note that when i remove the relationship between B and C everything works fine. It looks like TopLink gets confused when a one-to-one relationship is mapped on a column used for another field.

    In the scenario you mention (the Vendor repository), both the Phone Number and Fax Number fields are links to corresponding Qualified Lookup tables. These are inherently multi-value fields.
    Just for the sake of clarity - with the exception of Measurement type fields, it is only lookup fields that can be set to have multiple values. Refer to the matrix <a href="http://help.sap.com/saphelp_mdm550/helpdata/en/1f/2ddb4203d82b78e10000000a155106/content.htm">here</a>.
    Mark

  • DataSocket: Multiple writers. Can't get it to work!

    I made a datasocket ActiveX WEB component in VB which allow users to control data in a VI. But if more than one computer tries to connect, I got status error "Error: Can't connect to data item, another write connection exists."
    I have configure DataSocket ServerManger, Default Reader, Default Writer, Creators and SampleGroup as "everyhost" and Predefine Data: Items, SampleNum, SampleString, SampleBool with read and write access: SampleGroup and Allow Multible Writers.
    What are I doing wrong?
    Sometimes I do not get the errormessage but there is still just one user who can control.
    I must admit I don't understand fully the DataSocket ServerManger configure part and there is not much help
    to find at NI or Datasocket sites. (It is propably to simple) What are f.x. "Predefined Data Item" Is it the name of my DataSocketReader/Writer in the VI or the name of my datasocket in the VB code?

    Multiple writers can connect to the same DataSocket item, but not by default.
    When you create a connection to an item named "test" that is not predefined, it will allow Default Readers to read and only one Default Writer to write. This is because "test" was not listed in the predefined data items (from the DataSocket Server Manager) and follows the default case.
    In order to allow multiple writers on a DataSocket item, you need to predefine the item in the DataSocket Server Manager. So in the above case:
    1)Create a new item in the Predefined Data Items and name it "test"
    2)Set the read and write access parameters
    3)Check the allow multiple writer box
    You can now have multiple writers on the "test" item. Note that all of the predefined data items can have di
    fferent settings.
    There is also a KnowledgeBase article discussing this at:
    http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/a8ac9a751404bab18625672400630a3d?OpenDocument

  • Chapter Problem with Multiple Timeline Assets

    Using Premiere Pro 2.0 and DV assets exported from Premiere.
    Normally I just create a single export out of Premiere and all works well. This time I decided to try a different workflow, taking advantage of Encore's ability to add multiple assets to the same timeline. This way, I figured, if any changes are needed, only one part will have to be reexported and retranscoded, instead of the whole thing.
    So the first asset places in the timeline OK. The second asset generates a warning message, asking me if I want to "replace existing chapters with source marker in the asset".
    Now first of all, there are no existing chapters in the section of timeline where the new asset is being added, so I don't know why it's asking if I want to replace them. But that's a minor annoyance. The real problem is that all the chapter markers in the second asset, whether I click Yes or Cancel in response to the warning, end up squished towards the beginning of the second asset. The first chapter marker is correct, and all chapter markers thereafter are redistributed 12 frames apart from there. I only noticed this when I expanded the timeline view.
    I thought maybe I had exported from Premiere incorrectly, but if I remove the first asset and place the second asset in the timeline first, the chapters appear where they should. It seems that any asset after the first exhibits this squished marker syndrome, and I don't have a clue why, or how to fix it.
    Anyone have any ideas here?

    OK, I just tried replacing the middle timeline clip here. Logistically, it works.
    Here's what I did.
    1. New project. Add 3 pre-transcoded elementary mpeg and ac3 streams to the timeline.
    2. Check project.
    3. Fix the reported error about gaps between clips. Unfortunately, I had to move the 3rd clip 12 frames away from the 2nd clip. This will introduce a 12-frame gap between clips. I did not try to build with the error uncorrected. NB: There was no gap error concerning the boundary between clips 1 and 2, so I expect the problem is clip specific.
    4. Build a disc image. All of the audio was ac3, and with the different audio clip lengths (all less than 1/2 second difference), Encore re-transcoded the audio, and only the audio. My suggestion here is to use .wav files only.
    5. Use File>Replace Asset to replace the middle clip audio and video streams with new, shorter ones.
    6. Trim out the danger stripes in the timeline and butt the video and audio of the 3rd clip perfectly up against the end of the middle clip.
    7. Check project. No gap error this time.
    8. Build disc image.
    I mounted each image in turn and played them in WinDVD. They played as expected. I cannot speak to how truly seamless the playback is because all of the clips I have for testing fade to black at the end. But WinDVD did not hesitate when going from clip to clip and there were no freeze frames that I could see.
    So upgrading to CS3 will let you do what you want. It may be a perfect solution, and it may not, but it is certain to be better than what you get from En 1.5 going from timeline to timeline.

Maybe you are looking for