Java Bloomber V3 APIを使用すると通常動作します。ただし、特に再起動後、bbcomm.exeがバックグラウンドで実行されていないことがあります。 blp.exeを実行して手動で起動することはできますが、API経由でこれを行う方法があるのだろうかと思いました。Java v3 Bloomberg APIでbbcommを開始
私はまだヘルプ・ヘルプに待っている...
Java Bloomber V3 APIを使用すると通常動作します。ただし、特に再起動後、bbcomm.exeがバックグラウンドで実行されていないことがあります。 blp.exeを実行して手動で起動することはできますが、API経由でこれを行う方法があるのだろうかと思いました。Java v3 Bloomberg APIでbbcommを開始
私はまだヘルプ・ヘルプに待っている...
ヘルプデスクと話したところ、64ビットWindowsでは64ビットJVM bbcommで実行されていることが自動的に開始されないことが判明しました。これは32ビットJavaの下では発生しません - 32ビットbbcommの下で自動的に実行されます。
私の解決策は、問題がBloombergによって修正されるのを待つか(今は理解している)、この特定のケースを確認することです。
具体的なケースをチェックするには、次の64ビット・ウィンドウ(システムプロパティos.arch
)
java.vm.name
)bbcomm.exe
が実行されていないと仮定します。 bbcomm.exe
を使用して実行してください。Runtime.exec()
私は上記のテストをまだ行っていません。ブルームバーグが64ビットVMで持っているのとまったく同じ問題があるかもしれない。
bbcomm.exeは自動的V3 APIによって開始されました。
は実際に、それは時々ですが、時々ではありません。私は最終的な解決で回答を追加します –
問題を報告する必要があります。 APIクライアントライブラリ は、あなたがしようとしているものとまったく同じです。bbcommに接続できない場合は、起動を試みます。それがうまくいかない場合は、Bloombergに報告してください。 –
私は私の答えで提案したことをやり遂げました。私は、BBヘルプデスクを通って話していることを知っている人を得るという苦痛に煩わされることはありません。あなたがブルームバーグのために働いていれば、私に報告してもらうか、私に私にメッセージしてください。 –
.net APIを使用してWindows 7の64ビットマシンでも同じ問題が発生します。 bbcomm.exeが自動的に起動せず、唯一の回避策は "Bloomberg API DEMO"アプリケーションを起動することです。
ヘルプヘルプでしばらくお待ちいただいた後、bbcommはExcel APIを使用するか、APIデモを実行してください。しかし、Java APIから呼び出されたときに自動的に開始されるわけではありません。 HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
に値C:\blp\API\bbcomm.exe
でbbcomm
と呼ばれる文字列値を追加します - それは表示されたままになり、コマンド・ウィンドウを開き、そうではない:起動時に自動的にbbcommを開始するには、レジストリにエントリを追加すること
START /MIN C:\blp\API\bbcomm.exe
を作成し、それとレジストリのエントリを置き換えます既に提案されているコード。参考として、私は使用しているコードの下に投稿します。private final static Logger logger = LoggerFactory.getLogger(BloombergUtils.class);
private final static String BBCOMM_PROCESS = "bbcomm.exe";
private final static String BBCOMM_FOLDER = "C:/blp/API";
/**
*
* @return true if the bbcomm process is running
*/
public static boolean isBloombergProcessRunning() {
return ShellUtils.isProcessRunning(BBCOMM_PROCESS);
}
/**
* Starts the bbcomm process, which is required to connect to the Bloomberg data feed
* @return true if bbcomm was started successfully, false otherwise
*/
public static boolean startBloombergProcessIfNecessary() {
if (isBloombergProcessRunning()) {
logger.info(BBCOMM_PROCESS + " is started");
return true;
}
Callable<Boolean> startBloombergProcess = getStartingCallable();
return getResultWithTimeout(startBloombergProcess, 1, TimeUnit.SECONDS);
}
private static Callable<Boolean> getStartingCallable() {
return new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
logger.info("Starting " + BBCOMM_PROCESS + " manually");
ProcessBuilder pb = new ProcessBuilder(BBCOMM_PROCESS);
pb.directory(new File(BBCOMM_FOLDER));
pb.redirectErrorStream(true);
Process p = pb.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
if (line.toLowerCase().contains("started")) {
logger.info(BBCOMM_PROCESS + " is started");
return true;
}
}
return false;
}
};
}
private static boolean getResultWithTimeout(Callable<Boolean> startBloombergProcess, int timeout, TimeUnit timeUnit) {
ExecutorService executor = Executors.newSingleThreadExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r, "Bloomberg - bbcomm starter thread");
t.setDaemon(true);
return t;
}
});
Future<Boolean> future = executor.submit(startBloombergProcess);
try {
return future.get(timeout, timeUnit);
} catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
return false;
} catch (ExecutionException | TimeoutException e) {
logger.error("Could not start bbcomm", e);
return false;
} finally {
executor.shutdownNow();
try {
if (!executor.awaitTermination(100, TimeUnit.MILLISECONDS)) {
logger.warn("bbcomm starter thread still running");
}
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
}
ShellUtils.java
public class ShellUtils {
private final static Logger logger = LoggerFactory.getLogger(ShellUtils.class);
/**
* @return a list of processes currently running
* @throws RuntimeException if the request sent to the OS to get the list of running processes fails
*/
public static List<String> getRunningProcesses() {
List<String> processes = new ArrayList<>();
try {
Process p = Runtime.getRuntime().exec(System.getenv("windir") + "\\system32\\" + "tasklist.exe");
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
int i = 0;
while ((line = input.readLine()) != null) {
if (!line.isEmpty()) {
String process = line.split(" ")[0];
if (process.contains("exe")) {
processes.add(process);
}
}
}
} catch (IOException e) {
throw new RuntimeException("Could not retrieve the list of running processes from the OS");
}
return processes;
}
/**
*
* @param processName the name of the process, for example "explorer.exe"
* @return true if the process is currently running
* @throws RuntimeException if the request sent to the OS to get the list of running processes fails
*/
public static boolean isProcessRunning(String processName) {
List<String> processes = getRunningProcesses();
return processes.contains(processName);
}
}
私はこれを試してみました。 –