DelayQueue poll(long timeout, TimeUnit unit) not working
Im trying to test out using a DelayQueue but the poll method dosen't seem to be working properly. The docs say...
E poll(long timeout, TimeUnit unit)
Retrieves and removes the head of this queue, waiting if necessary up to the specified wait time if no elements with an unexpired delay are present on this queue.
The specified wait time is one second and the elements are delayed a lot longer than that.
Also my last if statement within the compareTo() method. What can I do to fix it? I had to add in the last return because I guess all the above return's are within conditional statements. Thanks.
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.DelayQueue;
public class DelayTest{
public static void main(String[] args){
DelayQueue<DelayedElement> dq = new DelayQueue<DelayedElement>();
dq.put(new DelayedElement(10));
dq.put(new DelayedElement(20));
dq.put(new DelayedElement(5));
try{
DelayedElement de = dq.take();
//DelayedElement de = dq.poll(1, TimeUnit.SECONDS);
// System.out.println(de.getDelayTime());
}catch(InterruptedException ie){
System.err.println(ie);
class DelayedElement implements Delayed, Comparable<Delayed>{
private long delay;
public long getDelay(TimeUnit unit){
long d = unit.convert(delay - (System.currentTimeMillis() / 1000), TimeUnit.SECONDS);
System.out.println(delay);
return delay;
public DelayedElement(long delay){
this.delay = delay;
public long getDelayTime(){
return delay;
public int compareTo(Delayed other){
if(other == this)
return 0;
DelayedElement x = (DelayedElement)other;
long diff = delay - x.delay;
if(diff < 0)
return -1;
else if (diff > 0)
return 1;
return 1;
}
Scrap that last question. I made some mods to the code and I switched to using take() which blocks. Problem is that take() is blocking forever. Can anyone see what I am doing wrong?
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.DelayQueue;
public class DelayTest{
public static void main(String[] args){
DelayQueue<DelayedElement> dq = new DelayQueue<DelayedElement>();
dq.put(new DelayedElement(10));
dq.put(new DelayedElement(20));
dq.put(new DelayedElement(5));
while(true){
try{
// DelayedElement de = dq.poll(); // if this queue has no elements with an unexpired delay no blocking
DelayedElement de = dq.take(); // waits for an expired element then remove head of queue
if(de == null) break;
System.out.println(de.getDelayTime());
}catch(InterruptedException ie){
System.err.println(ie);
class DelayedElement implements Delayed, Comparable<Delayed>{
private long delay;
public long getDelay(TimeUnit unit){
long d = unit.convert(delay, TimeUnit.MILLISECONDS);
return d;
public DelayedElement(long delay){
this.delay = delay;
public long getDelayTime(){
return delay;
public int compareTo(Delayed other){
if(other == this)
return 0;
DelayedElement x = (DelayedElement)other;
long diff = delay - x.delay;
if(diff < 0){
return -1;
return 1; // diff > 0
}
Similar Messages
-
DB Adapter polling as singleton process is not working as expected
Am using poller DB adapater to control the transaction per seconds to the downstream system and i want this poller process as singleton (One instance should be in running state at a time).
As suggested in oracle documents , below is the parameters configured in composite.xml file.
<service name="polling_Mange_Alert_Events"
ui:wsdlLocation="polling_Mange_Alert_Events.wsdl">
<interface.wsdl interface="http://xmlns.oracle.com/pcbpel/adapter/db/Application1/int_app_manageAlerts/polling_Mange_Alert_Events#wsdl.interface(polling_Mange_Alert_Events_ptt)"/>
<binding.jca config="polling_Mange_Alert_Events_db.jca">
<property name="singleton">true</property>
</binding.jca>
<property name="jca.retry.count" type="xs:int" many="false" override="may">2147483647</property>
<property name="jca.retry.interval" type="xs:int" many="false"
override="may">1</property>
<property name="jca.retry.backoff" type="xs:int" many="false"
override="may">2</property>
<property name="jca.retry.maxInterval" type="xs:string" many="false"
override="may">120</property>
</service>
Below is the JCA file parameters configured :
<adapter-config name="polling_Mange_Alert_Events" adapter="Database Adapter" wsdlLocation="polling_Mange_Alert_Events.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
<connection-factory location="eis/DB/vff-int-fus" UIConnectionName="PT_APPINFRA" adapterRef=""/>
<endpoint-activation portType="polling_Mange_Alert_Events_ptt" operation="receive">
<activation-spec className="oracle.tip.adapter.db.DBActivationSpec">
<property name="DescriptorName" value="polling_Mange_Alert_Events.ManageAlertEvents"/>
<property name="QueryName" value="polling_Mange_Alert_EventsSelect"/>
<property name="MappingsMetaDataURL" value="polling_Mange_Alert_Events-or-mappings.xml"/>
<property name="PollingStrategy" value="LogicalDeletePollingStrategy"/>
<property name="MarkReadColumn" value="TRANSACTION_STATUS"/>
<property name="MarkReadValue" value="Processing"/>
<property name="PollingInterval" value="10"/>
<property name="MaxRaiseSize" value="5"/>
<property name="MaxTransactionSize" value="5"/>
<property name="NumberOfThreads" value="1"/>
<property name="ReturnSingleResultSet" value="false"/>
<property name="MarkUnreadValue" value="Pending"/>
</activation-spec>
</endpoint-activation>
</adapter-config>
This poller process is running on clustered environment (2 soa nodes) and it is not working as expected as singleton process.
Please advise to solve this issue ?Hi,
1.Set Singleton property outside <binding.jca> like this:
<binding.jca config="polling_Mange_Alert_Events_db.jca"/>
<property name="singleton">true</property>
<property name="jca.retry.count" type="xs:int" many="false" override="may">2147483647</property>
<property name="jca.retry.interval" type="xs:int" many="false"
2.Also you can try setting these values in jca file:
<property name="RowsPerPollingInterval" value="100"/>
<property name="MaxTransactionSize" value="100"/>
3. try to increase the polling interval time.
Regards,
Anshul -
ALT Startup will not work any longer, PRAM reset will not work any longer.
Hi folks,
I just bought and plugged in my Mac Pro to a new Belkin battery back up unit yesterday, and now when I try to restart using the ALT key it will not work, it starts up to my default drive only. When I try to reset the PRAM, using the option-command P-R keys it also boots to the default drive.
Any suggestions would be appreciated.
JimTroubleshooting is sortof voodoo, if you do "a" and get response "b" then don't do it!
There have been other problems, USB hub, cable, etc.
OS X doesn't "need" PowerChute which also hasn't been updated in two years and can cause problems. APC works. APC's software for Windows is excellent though. Shame.
As for why... I'll leave that for philosophy class.
Wired keyboard? check. 1000VA or above? check. Any UPS also can have a strong EMF field around it that I guess could affect other electronics (cell phones etc and AC adapters have been known to cause problems and RFI). -
Whiteboard, Polls, Q&A and Powerpoint not working over Federation
Hi,
I have a problem with whiteboard, polls, Q&A and Powerpoint sharing over federation, if the federated endpoint is behind a web proxy with HTTPS inspection enabled. Audio, video and desktop sharing works fine.
Scenario:
2 Domains which are federated (DomainA and DomainB), all Lync servers are full patched (June 2014)
2 Users (UserA from DomainA and UserB from DomainB) works with full patched Lync Client 2013. Both Users work on their internal LAN. The client cannot reach the internet directly. Web requests go to through a proxy with HTTPS inspection.
1. UserA starts a Chat with UserB. UserB accepts.
2. UserA adds the whiteboard. UserB gets the "Add meeting content" button and accept.
3. UserA gets the whiteboard, UserB gets a error message "Because of network issues..."
In this scenario, UserB's Lync client tries to connect to WebConf Edge of DomainA over TCP/443 (HTTPS). Because UserB cannot reach the Internet directly from the inside LAN, the request goes trought the web proxy of DomainB (ProxyB). The web proxy is configured
with https inspection, so on the WebConfEdge I get requests from the web proxy of DomainB which are also answered by the WebConf Edge. On the pc of UserB I also get the answer, but signed with a certificate of the web proxy which is added as trusted root certificate
(normal behaviour if https inspection es enabled). On the network trace, as I can see, UserB resets (ACK, RESET) the connection to WebConf Edge directly after receiving the first https response.
Then I changed the web proxy (ProxyB) to bypass the https inspection for the ip address of the WebConf Edge of DomainA. The same scenario works fine now. It always works fine, if UserB have directly access to web conf edge of Domain A (UserB is in the internet
and not in the LAN).
I also could check this vice versa. It depends on which side, the conferencing is hosted. As soon as the other user connects through a web proxy which doesn't bypass the request directly, the user do not get the web conf content.
Then I tried with other domains and other environments, but all of them had the same issue, as long as the web request from the foreign user goes throug a web proxy. It seems there is no dependency on which product of web proxy will be used, it seems to
be a dependency on https inspection and all changes the web proxy do in this case with a web request and response.
I always tested with whiteboard, but the same behaviour is with Q&A and polls and also with Powerpoint (WAC). For Powerpoint it's only because the foreign user do not get the URL from web conf, so the client do not know how to connect to the WAC of DomainA.
During the tests with several Domains (customers), I see a corrupt "Client Hello" from a specific web proxy. In the list of cipher suites in the "Client Hello", the web proxy added an additional byte (0xFF) at the last TLSCipherSuites
entry, so the extensions, followed by the ciphersuites list in the "Client Hello" are not readable. So the connection will be reseted directly.
Because my workaround depends on the web proxy of the foreign side (configure bypass) it's not really a practicable way to make sure, the web conferencing content will work. Is there an other way to solve this issue?
Regards, StephanHi,
From your description, the issue should be the
https inspection on the web proxy, maybe you should change from the web proxy side.
You can refer to the link of
Enabling HTTPS Inspection causes some applications to stop working
Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or
information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.
Best Regards,
Eason Huang
Eason Huang
TechNet Community Support -
Apple TV will no longer Sync and YouTube Not Working
Recently my Apple TV (160GB version) has stopped syncing with my copy of iTunes.
Previously it synced fine and when ever I lunched iTunes it would show up under my devices. But now it behaves rather strangely. Every now and again my Apple TV shows up in iTunes (E.g. every few days for about 2 minutes when previously it was always there) and when I try and press the sync button it says it is syncing but nothing ever syncs.
Does anyone know what the problem might be?
Both my MacBook and Apple TV are connected wirelessly to an Apple AirPort Extreme (both are within range and show up as connected to the base station).
I have checked and I have iTunes music sharing allowed on my MacBook.
I also just noticed that my Apple TV no longer connects to You Tube (can't see any videos if I am signed in or not). Although in AirPort utility it says my Apple TV is connected to the base station (signal = -79, Noise = -92, Rate = 1) and my Apple TV says it's connected to the network.
I tried to in my Apple TV into my MacBook via a Ethernet cable (went into the sharing option in System Pref and started "Sharing your AirPort connection" to computers using "Built-in Ethernet") and it synced my content from iTunes but I still am unable to access You Tube. For example I go into the You Tube menu and click "Most Viewed" and it takes about 2-3 minutes to load the page before an error message is displayed.
I also noticed I can't watch any film trailers (although I only attempted to do this for the first time today), the names of the films come up with the description but the film image on the left and the actual trailer do not load. Do I need to open up extra ports on my MacBook to get this all to work?
Sorry if all that was very wordy but I love my little Apple TV as it lets me watch Podcasts and You Tube videos on my TV. Any help on getting this fixed would be really useful.
Message was edited by: amardiloWelcome to the discussion forums.
Try going to synching in the sources menu on your tv and selecting 'change itunes library', when it gives you the passcode check itunes to see if the tv is showing up as a new device, if so try entering the pass code. It may be that your tv is seeing itunes as a different library because of a recent upgrade. -
Timeout on httpclient not working in my app on windows phone 8
Hi,
In my app, I am calling a service method, which takes more than a minute to process and return the result to my app. I am using httpclient to do this. I have set the timeout for 2 minutes on the httpclient object. After one minute, I see webexception with
404 error code. looks like the default is set to 60 secs.
I was using webclient,httpwebrequest before, but after reading couple of sites, moved to httpclient. And my problem is not solved yet.
Am I missing something here? is 60 secs the fixed timeout for any network call in windows phone?
Appreciate your help. Thanks in advance.
Regards,
SaiThis has nothing to do with HttpClient. If you get a 404 you are getting a reply from the server saying whatever you are looking for is not on the server. Use something like fiddler to see the details of the http traffic from the emulator:
Configure the Windows Phone 8 Emulator to work with Fiddler
Jeff Sanders (MSFT)
@jsandersrocks - Windows Store Developer Solutions
@WSDevSol
Getting Started With Windows Azure Mobile Services development?
Click here
Getting Started With Windows Phone or Store app development?
Click here
My Team Blog: Windows Store & Phone Developer Solutions
My Blog: Http Client Protocol Issues (and other fun stuff I support) -
Time Capsule No Longer Available/Backing Up Not Working
Hi,
I have a MBP (this year's 15") running the latest verion of Lion. I've been using it with a Netgear router to connect to the Internet and also have the latest 2TB Time Capsule which is used strictly for Time Machine backups.
Never had a problem with this setup until a few weeks ago. My Time Machine backups are no longer working. When I try to run it I receive this message:
"Time Machine could not complete the backup. The backup disc image "/Volumes/(Scott Gross's Time Ca/Scott's MacBook Pro.sparsebundle" could not be accessed (error -1).
I"ve tried unplugging Time Capsule but that didn't seem to help too much. Any tips would be greatly appreciated.
Happy Thanksgiving!Thanks for the response Pondini. Unfortunately, it didn't work...the only thing I didn't try was this and that's because I'm using Lion and the instructions say Leopard only:
The backups may be corrupted. Try repairing them, per item C5.
How do I repair in Lion? Thanks! -
Hi,
I no longer have my former laptop.
It had a library of bookmarks in Firefox.
I did set up Firefox to attach it to an account, so the bookmarks should still be there.
I see that if I do Sync, I can possibly overwrite the bookmarks if I do it twice.
My hope is to first confirm the bookmarks are in the system somewhere,
and then find out how to retrieve them.
I thought I registered my new Firefox with the other account, but no bookmarks appeared.
Would be so grateful for help. Very important research etc. was stored there :)
Thank you,
SkylarDid you use Sync before with that laptop that you no longer have?
You would still need a backup copy of the Sync key that was used to be able to access data stored in that account.
If you have this Sync key then a possibility is to create a second Firefox profile folder and see if you can connect to the Sync account.
You can use the Profile Manager to create another profile.
*http://kb.mozillazine.org/Profile_Manager
*https://support.mozilla.org/kb/Managing+profiles
Create a new profile as a test to check if your current profile is causing the problem.
See also:
*http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox -
Alum BT keyboard does not work after wake up - but BT trackpad does!
Here is my set up:
MBAir 2011 model (13", i7 4GB, Lion.. all up to date)
Desktop set up (same at work and home)
- Thunderbolt display
- Aluminum Bluetooth Keyboard
- Aluminum Bluetooth Trackpad
What I do:
- Plug in the sleeping mbair into my display via thunderbolt and power cable
- Wake up using external bluetooth trackpad
- computer wakes up and external trackpad is functional (it always works)
- 7/10 times the external keyboard will not connect to enter password to get into system
- I have tried power button banging on it for a long time and does not work
- open mbair and type password in and remove keyboard and repair and after several tried it will work
- then I can close mbair and use external keyboard
- painful to do this most days at home and work
What have I tried
- PRAM, SMC reset
- remove all BT entries - trash blutooth properties files and freshly add them back
- I have tried waking using keyboard as well and it does not work
Only think I have wanted to try and have not found out is, if keyboard can reset to factory.
Yes I also have the occasionaly wifi not connecting from sleep issueHello
Have you noticed this problem on factory settings or only on your Windows 7 installation? Maybe its just a driver or software issue
Make also sure that latest BIOS version is installed. Look on the Toshiba website for an update:
http://eu.computers.toshiba-europe.com > Support & Downloads > Download Drivers
Before you start the update, make sure that all programs are closed and you are logged in as Administrator. -
Okay, among the LONG list of things not working since the update, is the Mac Mail search function. I will type in a search for emails from someone (eg. my son, partner, BFF, etc. who email me all the time), and either the system can't find emails from him, can only find ones sent years ago, or produces a list that is not in newest to oldest order (dates all mixed up).
I really rely on my being able to use my mail easily for personal and work use. It's really sad when my other mailbox (Outlook) is working better than mac mail.
Any advice?Okay, among the LONG list of things not working since the update, is the Mac Mail search function. I will type in a search for emails from someone (eg. my son, partner, BFF, etc. who email me all the time), and either the system can't find emails from him, can only find ones sent years ago, or produces a list that is not in newest to oldest order (dates all mixed up).
I really rely on my being able to use my mail easily for personal and work use. It's really sad when my other mailbox (Outlook) is working better than mac mail.
Any advice? -
Revision: 3913
Author: [email protected]
Date: 2008-10-27 13:49:02 -0700 (Mon, 27 Oct 2008)
Log Message:
BLZ-272 Two long polling endpoints not working in same app with Firefox
The long polling waitMonitor object in the FlexSession did not keep track of
blocking polls via endpoint ID. This prevented the second channel from blocking.
Enhance the FlexSession.waitMonitor to be a map of endpointID to
EndpointQueue objects, and keep track of the monitors based on what endpoint
they are associated with.
QA: Yes
Doc:No
Checkintests: passed
Ticket Links:
http://bugs.adobe.com/jira/browse/BLZ-272
Modified Paths:
blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/FlexSession.java
blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/client/FlexClient.javaRevision: 3913
Author: [email protected]
Date: 2008-10-27 13:49:02 -0700 (Mon, 27 Oct 2008)
Log Message:
BLZ-272 Two long polling endpoints not working in same app with Firefox
The long polling waitMonitor object in the FlexSession did not keep track of
blocking polls via endpoint ID. This prevented the second channel from blocking.
Enhance the FlexSession.waitMonitor to be a map of endpointID to
EndpointQueue objects, and keep track of the monitors based on what endpoint
they are associated with.
QA: Yes
Doc:No
Checkintests: passed
Ticket Links:
http://bugs.adobe.com/jira/browse/BLZ-272
Modified Paths:
blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/FlexSession.java
blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/client/FlexClient.java -
af:poll not working in adf table
Hi All,
Does anyone have tried create timer using <af:poll inside a table?, i have a problem like this:
<trh:script>
var count=0;
var timer;
var sec;
var min;
function startCount(event){
inputField = event.getSource().findComponent("totalTime");
inputField.setValue(timer);
count=count+1;
sec = Math.floor(count / 100);
min = Math.floor(count / 6000);
hour = Math.floor(count / 360000);
if (sec >= 60) {
sec = sec - 60 * min;
if (min >= 60) {
min = min - 60 * hour;
timer = pad2(hour) + ':' + pad2(min) + ':' + pad2(sec);
function startAndStopPoll(event) {
event.cancel();
var poll = AdfPage.PAGE.findComponent("poll");
if (0 > poll.getInterval())
poll.setInterval(10);
else
poll.setInterval(-1);
function pad2(number) {
return (10 > number) ? '0' + number : number;
</trh:script>
then if i put this script :
<af:panelFormLayout>
<af:poll id="poll" interval="-1">
<af:clientListener type="poll" method="startCount"/>
</af:poll>
<af:inputText label="Total Time" id="totalTime" shortDesc="Total time" clientComponent="true"
value="00:00:00"/>
</af:panelFormLayout>
<af:panelGroupLayout layout="horizontal">
<af:commandButton text="Start and Stop Poll" id="button">
<af:clientListener type="action" method="startAndStopPoll"/>
</af:commandButton>
</af:panelGroupLayout>
out side the table it is working, but if i put that script inside the table it is not working.. does any one know what happen with the script?
Regards,
Hadi WijayaHi Frank,
Actually i want create timer to record how long does customer service (CS) spend the speaking time with each customer. and the scenario is like this :
1. customer call the CS
2. CS click add button to start a new record in the table
3. then one of table column has start/stop button and one input text which is the input text will be filled by timer like stopwatch (00:00:00)
4. then CS click the start/stop button to start the timer.
5. button stop pressed by the CS after call is over.
6. CS will add new row for next customer again and again
Do you have a suggestion for scenario like this?
Regards,
Hadi Wijaya
Edited by: Hadi Wijaya on Jul 1, 2009 12:02 AM -
Timeout script not working quite right.
I'm doing a kiosk project that has 11 scenes that house about
70 videos for playback. I need to include a timeout function that
needs to revert back to screen #1 if there is no mouse activity for
around 8 minutes. There is another timeout script in scene #2 that
forwards ahead to scene #3 if no activity within 30 seconds. The
timeouts do seem to work, they go to and stop where they're
supposed to but then they seem to rerun themselves so that several
are running at the same time. When I click into other scenes which
start the videos, then they will quit and jump back to screen #1
after 30 seconds or so.
Any help on this would be greatly appreciated...You're posting AS2 code in the AS3 forum. Anyways, Try moving
your mouse around while you're watching the videos and see if they
kick back to the first scene... chances are myInterval is still
working in the other scenes.
I'm not sure, but I don't think changing scenes cancels that
kind of functionality. From what I heard, when you work with
scenes, when the file is compiled, it melds them all into one long
timeline (hear-say only, so I won't mind being straightened out on
that). -
Hello,
I used the queries timeout attribute to catch exception when
the timeout is fired. I used Oracle driver on coldfusion 7.0.1.
I have long quires and they caused the coldfuion hanged
becuase the timeout not work. please help me in this issue
ASAP.I used the queries timeout attribute to catch exception when the
timeout
is fired. I used Oracle driver on coldfusion 7.0.1.
I have long quires and they caused the coldfuion hanged
becuase the
timeout not work. please help me in this issue ASAP.
I would not use the timeout attribute. I would check for
mistakes in the Coldfusion code and in the query. -
All my music was on prior to syncing. The sync deleted all my music. I can now no longer add any music. I have the "sync music" checked. Restoring factory settings did not work. Any thoughts?
When you synced with iTunes It would have tried to replace the music on the iPhone with what is on the computer. which is what happens when you sync with iTunes.
If the songs are purchased you can re-downloaded them Pretty easily. You mentioned that you still see the songs and that you could not play them. Do they have a Cloud symbol next to them? If so this means that you can download them but that they are not on the device.
Maybe you are looking for
-
ASA 5505 rookie - can't ping remote site or vice versa
Hi, I'm trying to setup an ipsec from an ASA 5505 (8.4) to a Sophos UTM (9.2) Internet etc is up and accessible. Ipsec tunnel is up also but I can't pass traffic through it. I get this message in the logs: 3 Aug 05 2014 22:38:52 81.111.111.156 82.222
-
Problem accessing ESS tab in new installation
FYI We have just installed EP 6.0 and when trying to access the ESS tab we get the following error, I'm sure something is not set up correctly but we are having difficulty determining what it is. any help would be appreciated. An error has occurred:
-
Error Writing Xml Table to the application server
Hi All , I am converting a internal table into a XML table using Fm SAP_CONVERT_TO_XML_FORMAT, And then writing it to the application server , at the end of the file which is written to application server there are some junk characters . when i down
-
Not able to view the web report..
hi, I have sap bw 3.0b and WAD installed. I am able to create a report in WAD and when i try to generate the web report, IE opens with an url starting as http://xxx.yyy..... If my understanding is correct to view these WAD reports in my workstation I
-
Air Port Extreme connection problems
I have a Macbook Pro and a 1st gen. Ipod connected to the Internet using an Air Port Extreme. At this time I cannot use two devices at once to access the Internet, only one or the other. What should I do to adjust settings on my Airport?